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
tBaxter/activity-monitor
activity_monitor/templatetags/activity_tags.py
https://github.com/tBaxter/activity-monitor/blob/be6c6edc7c6b4141923b47376502cde0f785eb68/activity_monitor/templatetags/activity_tags.py#L14-L34
def join_and(value): """Given a list of strings, format them with commas and spaces, but with 'and' at the end. >>> join_and(['apples', 'oranges', 'pears']) "apples, oranges, and pears" There is surely a better home for this """ # convert numbers to strings value = [str(item) for item...
[ "def", "join_and", "(", "value", ")", ":", "# convert numbers to strings", "value", "=", "[", "str", "(", "item", ")", "for", "item", "in", "value", "]", "if", "len", "(", "value", ")", "==", "1", ":", "return", "value", "[", "0", "]", "if", "len", ...
Given a list of strings, format them with commas and spaces, but with 'and' at the end. >>> join_and(['apples', 'oranges', 'pears']) "apples, oranges, and pears" There is surely a better home for this
[ "Given", "a", "list", "of", "strings", "format", "them", "with", "commas", "and", "spaces", "but", "with", "and", "at", "the", "end", "." ]
python
train
26.761905
sibirrer/lenstronomy
lenstronomy/Cosmo/lens_cosmo.py
https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Cosmo/lens_cosmo.py#L247-L255
def D_d(self, H_0, Om0, Ode0=None): """ angular diameter to deflector :param H_0: Hubble parameter [km/s/Mpc] :param Om0: normalized matter density at present time :return: float [Mpc] """ lensCosmo = self._get_cosom(H_0, Om0, Ode0) return lensCosmo.D_d
[ "def", "D_d", "(", "self", ",", "H_0", ",", "Om0", ",", "Ode0", "=", "None", ")", ":", "lensCosmo", "=", "self", ".", "_get_cosom", "(", "H_0", ",", "Om0", ",", "Ode0", ")", "return", "lensCosmo", ".", "D_d" ]
angular diameter to deflector :param H_0: Hubble parameter [km/s/Mpc] :param Om0: normalized matter density at present time :return: float [Mpc]
[ "angular", "diameter", "to", "deflector", ":", "param", "H_0", ":", "Hubble", "parameter", "[", "km", "/", "s", "/", "Mpc", "]", ":", "param", "Om0", ":", "normalized", "matter", "density", "at", "present", "time", ":", "return", ":", "float", "[", "Mp...
python
train
34.333333
agile-geoscience/striplog
striplog/rock.py
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/rock.py#L14-L25
def Rock(*args, **kwargs): """ Graceful deprecation for old class name. """ with warnings.catch_warnings(): warnings.simplefilter("always") w = "The 'Rock' class was renamed 'Component'. " w += "Please update your code." warnings.warn(w, DeprecationWarning, stacklevel=2)...
[ "def", "Rock", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "warnings", ".", "catch_warnings", "(", ")", ":", "warnings", ".", "simplefilter", "(", "\"always\"", ")", "w", "=", "\"The 'Rock' class was renamed 'Component'. \"", "w", "+=", "\"P...
Graceful deprecation for old class name.
[ "Graceful", "deprecation", "for", "old", "class", "name", "." ]
python
test
29
albu/albumentations
albumentations/augmentations/bbox_utils.py
https://github.com/albu/albumentations/blob/b31393cd6126516d37a84e44c879bd92c68ffc93/albumentations/augmentations/bbox_utils.py#L23-L34
def denormalize_bbox(bbox, rows, cols): """Denormalize coordinates of a bounding box. Multiply x-coordinates by image width and y-coordinates by image height. This is an inverse operation for :func:`~albumentations.augmentations.bbox.normalize_bbox`. """ if rows == 0: raise ValueError('Argument ...
[ "def", "denormalize_bbox", "(", "bbox", ",", "rows", ",", "cols", ")", ":", "if", "rows", "==", "0", ":", "raise", "ValueError", "(", "'Argument rows cannot be zero'", ")", "if", "cols", "==", "0", ":", "raise", "ValueError", "(", "'Argument cols cannot be zer...
Denormalize coordinates of a bounding box. Multiply x-coordinates by image width and y-coordinates by image height. This is an inverse operation for :func:`~albumentations.augmentations.bbox.normalize_bbox`.
[ "Denormalize", "coordinates", "of", "a", "bounding", "box", ".", "Multiply", "x", "-", "coordinates", "by", "image", "width", "and", "y", "-", "coordinates", "by", "image", "height", ".", "This", "is", "an", "inverse", "operation", "for", ":", "func", ":",...
python
train
47.916667
quantopian/zipline
zipline/utils/argcheck.py
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/argcheck.py#L98-L120
def parse_argspec(callable_): """ Takes a callable and returns a tuple with the list of Argument objects, the name of *args, and the name of **kwargs. If *args or **kwargs is not present, it will be None. This returns a namedtuple called Argspec that has three fields named: ...
[ "def", "parse_argspec", "(", "callable_", ")", ":", "args", ",", "varargs", ",", "keywords", ",", "defaults", "=", "getargspec", "(", "callable_", ")", "defaults", "=", "list", "(", "defaults", "or", "[", "]", ")", "if", "getattr", "(", "callable_", ",",...
Takes a callable and returns a tuple with the list of Argument objects, the name of *args, and the name of **kwargs. If *args or **kwargs is not present, it will be None. This returns a namedtuple called Argspec that has three fields named: args, starargs, and kwargs.
[ "Takes", "a", "callable", "and", "returns", "a", "tuple", "with", "the", "list", "of", "Argument", "objects", "the", "name", "of", "*", "args", "and", "the", "name", "of", "**", "kwargs", ".", "If", "*", "args", "or", "**", "kwargs", "is", "not", "pr...
python
train
38.782609
google/pinject
pinject/binding_keys.py
https://github.com/google/pinject/blob/888acf1ccaaeeeba28a668ef9158c9dcc94405e1/pinject/binding_keys.py#L55-L68
def new(arg_name, annotated_with=None): """Creates a BindingKey. Args: arg_name: the name of the bound arg annotation: an Annotation, or None to create an unannotated binding key Returns: a new BindingKey """ if annotated_with is not None: annotation = annotations.Annotati...
[ "def", "new", "(", "arg_name", ",", "annotated_with", "=", "None", ")", ":", "if", "annotated_with", "is", "not", "None", ":", "annotation", "=", "annotations", ".", "Annotation", "(", "annotated_with", ")", "else", ":", "annotation", "=", "annotations", "."...
Creates a BindingKey. Args: arg_name: the name of the bound arg annotation: an Annotation, or None to create an unannotated binding key Returns: a new BindingKey
[ "Creates", "a", "BindingKey", "." ]
python
train
30.428571
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/xyz_functions.py
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/xyz_functions.py#L421-L442
def get_kabsch_rotation(Q, P): """Calculate the optimal rotation from ``P`` unto ``Q``. Using the Kabsch algorithm the optimal rotation matrix for the rotation of ``other`` unto ``self`` is calculated. The algorithm is described very well in `wikipedia <http://en.wikipedia.org/wiki/Kabsch_algorithm...
[ "def", "get_kabsch_rotation", "(", "Q", ",", "P", ")", ":", "# Naming of variables follows the wikipedia article:", "# http://en.wikipedia.org/wiki/Kabsch_algorithm", "A", "=", "np", ".", "dot", "(", "np", ".", "transpose", "(", "P", ")", ",", "Q", ")", "# One can't...
Calculate the optimal rotation from ``P`` unto ``Q``. Using the Kabsch algorithm the optimal rotation matrix for the rotation of ``other`` unto ``self`` is calculated. The algorithm is described very well in `wikipedia <http://en.wikipedia.org/wiki/Kabsch_algorithm>`_. Args: other (Cartesi...
[ "Calculate", "the", "optimal", "rotation", "from", "P", "unto", "Q", "." ]
python
train
35.818182
DataKitchen/DKCloudCommand
DKCloudCommand/cli/__main__.py
https://github.com/DataKitchen/DKCloudCommand/blob/1cf9cb08ab02f063eef6b5c4b327af142991daa3/DKCloudCommand/cli/__main__.py#L390-L397
def kitchen_config(backend, kitchen, add, get, unset, listall): """ Get and Set Kitchen variable overrides """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) check_and_print(DKCloudCommandRunner.config_kitchen(bac...
[ "def", "kitchen_config", "(", "backend", ",", "kitchen", ",", "add", ",", "get", ",", "unset", ",", "listall", ")", ":", "err_str", ",", "use_kitchen", "=", "Backend", ".", "get_kitchen_from_user", "(", "kitchen", ")", "if", "use_kitchen", "is", "None", ":...
Get and Set Kitchen variable overrides
[ "Get", "and", "Set", "Kitchen", "variable", "overrides" ]
python
train
45.25
python-diamond/Diamond
src/diamond/handler/datadog.py
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/datadog.py#L84-L106
def _send(self): """ Take metrics from queue and send it to Datadog API """ while len(self.queue) > 0: metric = self.queue.popleft() path = '%s.%s.%s' % ( metric.getPathPrefix(), metric.getCollectorPath(), metric.g...
[ "def", "_send", "(", "self", ")", ":", "while", "len", "(", "self", ".", "queue", ")", ">", "0", ":", "metric", "=", "self", ".", "queue", ".", "popleft", "(", ")", "path", "=", "'%s.%s.%s'", "%", "(", "metric", ".", "getPathPrefix", "(", ")", ",...
Take metrics from queue and send it to Datadog API
[ "Take", "metrics", "from", "queue", "and", "send", "it", "to", "Datadog", "API" ]
python
train
27.608696
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L3645-L3689
def edterm(trmtyp, source, target, et, fixref, abcorr, obsrvr, npts): """ Compute a set of points on the umbral or penumbral terminator of a specified target body, where the target shape is modeled as an ellipsoid. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/edterm_c.html :param tr...
[ "def", "edterm", "(", "trmtyp", ",", "source", ",", "target", ",", "et", ",", "fixref", ",", "abcorr", ",", "obsrvr", ",", "npts", ")", ":", "trmtyp", "=", "stypes", ".", "stringToCharP", "(", "trmtyp", ")", "source", "=", "stypes", ".", "stringToCharP...
Compute a set of points on the umbral or penumbral terminator of a specified target body, where the target shape is modeled as an ellipsoid. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/edterm_c.html :param trmtyp: Terminator type. :type trmtyp: str :param source: Light source. ...
[ "Compute", "a", "set", "of", "points", "on", "the", "umbral", "or", "penumbral", "terminator", "of", "a", "specified", "target", "body", "where", "the", "target", "shape", "is", "modeled", "as", "an", "ellipsoid", "." ]
python
train
35.577778
welbornprod/colr
colr/controls.py
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L109-L125
def erase_line(method=EraseMethod.ALL, file=sys.stdout): """ Erase a line, or part of a line. See `method` argument below. Cursor position does not change. Esc[<method>K Arguments: method : One of these possible values: EraseMethod.END or 0: ...
[ "def", "erase_line", "(", "method", "=", "EraseMethod", ".", "ALL", ",", "file", "=", "sys", ".", "stdout", ")", ":", "erase", ".", "line", "(", "method", ")", ".", "write", "(", "file", "=", "file", ")" ]
Erase a line, or part of a line. See `method` argument below. Cursor position does not change. Esc[<method>K Arguments: method : One of these possible values: EraseMethod.END or 0: Clear from cursor to the end of the line. ...
[ "Erase", "a", "line", "or", "part", "of", "a", "line", ".", "See", "method", "argument", "below", ".", "Cursor", "position", "does", "not", "change", "." ]
python
train
39.764706
waqasbhatti/astrobase
astrobase/lcproc/lcbin.py
https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/lcproc/lcbin.py#L290-L379
def parallel_timebin(lclist, binsizesec, maxobjects=None, outdir=None, lcformat='hat-sql', lcformatdir=None, timecols=None, magcols=None, errcols=None, ...
[ "def", "parallel_timebin", "(", "lclist", ",", "binsizesec", ",", "maxobjects", "=", "None", ",", "outdir", "=", "None", ",", "lcformat", "=", "'hat-sql'", ",", "lcformatdir", "=", "None", ",", "timecols", "=", "None", ",", "magcols", "=", "None", ",", "...
This time-bins all the LCs in the list using the specified bin size. Parameters ---------- lclist : list of str The input LCs to process. binsizesec : float The time bin size to use in seconds. maxobjects : int or None If provided, LC processing will stop at `lclist[maxob...
[ "This", "time", "-", "bins", "all", "the", "LCs", "in", "the", "list", "using", "the", "specified", "bin", "size", "." ]
python
valid
34.411111
philgyford/django-spectator
spectator/events/migrations/0024_event_venue_name.py
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/events/migrations/0024_event_venue_name.py#L7-L16
def forwards(apps, schema_editor): """ Set the venue_name field of all Events that have a Venue. """ Event = apps.get_model('spectator_events', 'Event') for event in Event.objects.all(): if event.venue is not None: event.venue_name = event.venue.name event.save()
[ "def", "forwards", "(", "apps", ",", "schema_editor", ")", ":", "Event", "=", "apps", ".", "get_model", "(", "'spectator_events'", ",", "'Event'", ")", "for", "event", "in", "Event", ".", "objects", ".", "all", "(", ")", ":", "if", "event", ".", "venue...
Set the venue_name field of all Events that have a Venue.
[ "Set", "the", "venue_name", "field", "of", "all", "Events", "that", "have", "a", "Venue", "." ]
python
train
30.7
hsolbrig/dirlistproc
dirlistproc/DirectoryListProcessor.py
https://github.com/hsolbrig/dirlistproc/blob/3d5dedeb2bc653b409a476d91c8a4e30eb6a08ad/dirlistproc/DirectoryListProcessor.py#L98-L112
def decode_file_args(self, argv: List[str]) -> List[str]: """ Preprocess any arguments that begin with the fromfile prefix char(s). This replaces the one in Argparse because it a) doesn't process "-x y" correctly and b) ignores bad files :param argv: raw options l...
[ "def", "decode_file_args", "(", "self", ",", "argv", ":", "List", "[", "str", "]", ")", "->", "List", "[", "str", "]", ":", "for", "arg", "in", "[", "arg", "for", "arg", "in", "argv", "if", "arg", "[", "0", "]", "in", "self", ".", "fromfile_prefi...
Preprocess any arguments that begin with the fromfile prefix char(s). This replaces the one in Argparse because it a) doesn't process "-x y" correctly and b) ignores bad files :param argv: raw options list :return: options list with file references replaced
[ "Preprocess", "any", "arguments", "that", "begin", "with", "the", "fromfile", "prefix", "char", "(", "s", ")", ".", "This", "replaces", "the", "one", "in", "Argparse", "because", "it", "a", ")", "doesn", "t", "process", "-", "x", "y", "correctly", "and",...
python
valid
44.4
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L1531-L1559
def shift_or_mirror_into_invertible_domain(self, solution_genotype, copy=False): """Details: input ``solution_genotype`` is changed. The domain is [lb - al, ub + au] and in [lb - 2*al - (ub - lb) / 2, lb - al] mirroring is applied. """ ...
[ "def", "shift_or_mirror_into_invertible_domain", "(", "self", ",", "solution_genotype", ",", "copy", "=", "False", ")", ":", "assert", "solution_genotype", "is", "not", "None", "if", "copy", ":", "y", "=", "[", "val", "for", "val", "in", "solution_genotype", "...
Details: input ``solution_genotype`` is changed. The domain is [lb - al, ub + au] and in [lb - 2*al - (ub - lb) / 2, lb - al] mirroring is applied.
[ "Details", ":", "input", "solution_genotype", "is", "changed", ".", "The", "domain", "is", "[", "lb", "-", "al", "ub", "+", "au", "]", "and", "in", "[", "lb", "-", "2", "*", "al", "-", "(", "ub", "-", "lb", ")", "/", "2", "lb", "-", "al", "]"...
python
train
42.862069
Neurita/boyle
boyle/nifti/check.py
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/check.py#L295-L316
def repr_imgs(imgs): """Printing of img or imgs""" if isinstance(imgs, string_types): return imgs if isinstance(imgs, collections.Iterable): return '[{}]'.format(', '.join(repr_imgs(img) for img in imgs)) # try get_filename try: filename = imgs.get_filename() if fil...
[ "def", "repr_imgs", "(", "imgs", ")", ":", "if", "isinstance", "(", "imgs", ",", "string_types", ")", ":", "return", "imgs", "if", "isinstance", "(", "imgs", ",", "collections", ".", "Iterable", ")", ":", "return", "'[{}]'", ".", "format", "(", "', '", ...
Printing of img or imgs
[ "Printing", "of", "img", "or", "imgs" ]
python
valid
36.454545
zblz/naima
naima/extern/minimize.py
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/extern/minimize.py#L70-L243
def _minimize_neldermead( func, x0, args=(), callback=None, xtol=1e-4, ftol=1e-4, maxiter=None, maxfev=None, disp=False, return_all=False, ): # pragma: no cover """ Minimization of scalar function of one or more variables using the Nelder-Mead algorithm. Options...
[ "def", "_minimize_neldermead", "(", "func", ",", "x0", ",", "args", "=", "(", ")", ",", "callback", "=", "None", ",", "xtol", "=", "1e-4", ",", "ftol", "=", "1e-4", ",", "maxiter", "=", "None", ",", "maxfev", "=", "None", ",", "disp", "=", "False",...
Minimization of scalar function of one or more variables using the Nelder-Mead algorithm. Options for the Nelder-Mead algorithm are: disp : bool Set to True to print convergence messages. xtol : float Relative error in solution `xopt` acceptable for convergence. ...
[ "Minimization", "of", "scalar", "function", "of", "one", "or", "more", "variables", "using", "the", "Nelder", "-", "Mead", "algorithm", "." ]
python
train
26.770115
jmcgeheeiv/pyfakefs
pyfakefs/fake_filesystem.py
https://github.com/jmcgeheeiv/pyfakefs/blob/6c36fb8987108107fc861fc3013620d46c7d2f9c/pyfakefs/fake_filesystem.py#L915-L926
def reset(self, total_size=None): """Remove all file system contents and reset the root.""" self.root = FakeDirectory(self.path_separator, filesystem=self) self.cwd = self.root.name self.open_files = [] self._free_fd_heap = [] self._last_ino = 0 self._last_dev = ...
[ "def", "reset", "(", "self", ",", "total_size", "=", "None", ")", ":", "self", ".", "root", "=", "FakeDirectory", "(", "self", ".", "path_separator", ",", "filesystem", "=", "self", ")", "self", ".", "cwd", "=", "self", ".", "root", ".", "name", "sel...
Remove all file system contents and reset the root.
[ "Remove", "all", "file", "system", "contents", "and", "reset", "the", "root", "." ]
python
train
36.25
PhilippeFerreiraDeSousa/bitext-matching
lib/enpc_aligner/IBM2_func.py
https://github.com/PhilippeFerreiraDeSousa/bitext-matching/blob/195c3e98775cfa5e63e4bb0bb1da6f741880d980/lib/enpc_aligner/IBM2_func.py#L85-L102
def viterbi_alignment(es, fs, t, a): ''' return dictionary e in es -> f in fs ''' max_a = collections.defaultdict(float) l_e = len(es) l_f = len(fs) for (j, e) in enumerate(es, 1): current_max = (0, -1) for (i, f) in enumerate(fs, 1): ...
[ "def", "viterbi_alignment", "(", "es", ",", "fs", ",", "t", ",", "a", ")", ":", "max_a", "=", "collections", ".", "defaultdict", "(", "float", ")", "l_e", "=", "len", "(", "es", ")", "l_f", "=", "len", "(", "fs", ")", "for", "(", "j", ",", "e",...
return dictionary e in es -> f in fs
[ "return", "dictionary", "e", "in", "es", "-", ">", "f", "in", "fs" ]
python
train
29.944444
cloudsmith-io/cloudsmith-cli
cloudsmith_cli/cli/commands/check.py
https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/check.py#L34-L76
def rates(ctx, opts): """Check current API rate limits.""" click.echo("Retrieving rate limits ... ", nl=False) context_msg = "Failed to retrieve status!" with handle_api_exceptions(ctx, opts=opts, context_msg=context_msg): with maybe_spinner(opts): resources_limits = get_rate_limits...
[ "def", "rates", "(", "ctx", ",", "opts", ")", ":", "click", ".", "echo", "(", "\"Retrieving rate limits ... \"", ",", "nl", "=", "False", ")", "context_msg", "=", "\"Failed to retrieve status!\"", "with", "handle_api_exceptions", "(", "ctx", ",", "opts", "=", ...
Check current API rate limits.
[ "Check", "current", "API", "rate", "limits", "." ]
python
train
34.860465
IceflowRE/unidown
unidown/plugin/a_plugin.py
https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/plugin/a_plugin.py#L339-L379
def load_save_state(self) -> SaveState: """ Load the savestate of the plugin. :return: savestate :rtype: ~unidown.plugin.save_state.SaveState :raises ~unidown.plugin.exceptions.PluginException: broken savestate json :raises ~unidown.plugin.exceptions.PluginException: dif...
[ "def", "load_save_state", "(", "self", ")", "->", "SaveState", ":", "if", "not", "self", ".", "_save_state_file", ".", "exists", "(", ")", ":", "self", ".", "log", ".", "info", "(", "\"No savestate file found.\"", ")", "return", "SaveState", "(", "dynamic_da...
Load the savestate of the plugin. :return: savestate :rtype: ~unidown.plugin.save_state.SaveState :raises ~unidown.plugin.exceptions.PluginException: broken savestate json :raises ~unidown.plugin.exceptions.PluginException: different savestate versions :raises ~unidown.plugin.ex...
[ "Load", "the", "savestate", "of", "the", "plugin", "." ]
python
train
50.390244
SmokinCaterpillar/pypet
pypet/trajectory.py
https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/trajectory.py#L3567-L3589
def f_get_derived_parameters(self, fast_access=False, copy=True): """ Returns a dictionary containing the full parameter names as keys and the parameters or the parameter data items as values. :param fast_access: Determines whether the parameter objects or their values are return...
[ "def", "f_get_derived_parameters", "(", "self", ",", "fast_access", "=", "False", ",", "copy", "=", "True", ")", ":", "return", "self", ".", "_return_item_dictionary", "(", "self", ".", "_derived_parameters", ",", "fast_access", ",", "copy", ")" ]
Returns a dictionary containing the full parameter names as keys and the parameters or the parameter data items as values. :param fast_access: Determines whether the parameter objects or their values are returned in the dictionary. :param copy: Whether t...
[ "Returns", "a", "dictionary", "containing", "the", "full", "parameter", "names", "as", "keys", "and", "the", "parameters", "or", "the", "parameter", "data", "items", "as", "values", "." ]
python
test
36.130435
Unbabel/unbabel-py
unbabel/api.py
https://github.com/Unbabel/unbabel-py/blob/3bd6397174e184d89d2a11149d87be5d12570c64/unbabel/api.py#L370-L387
def get_translations(self, status=None): ''' Returns the translations requested by the user ''' if status is not None: result = self.api_call('translation/?status=%s' % status) else: result = self.api_call('translation/') if result.status_code ...
[ "def", "get_translations", "(", "self", ",", "status", "=", "None", ")", ":", "if", "status", "is", "not", "None", ":", "result", "=", "self", ".", "api_call", "(", "'translation/?status=%s'", "%", "status", ")", "else", ":", "result", "=", "self", ".", ...
Returns the translations requested by the user
[ "Returns", "the", "translations", "requested", "by", "the", "user" ]
python
train
38.611111
openstack/monasca-common
monasca_common/kafka_lib/protocol.py
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/protocol.py#L565-L586
def decode_offset_fetch_response(cls, data): """ Decode bytes to an OffsetFetchResponse Arguments: data: bytes to decode """ ((correlation_id,), cur) = relative_unpack('>i', data, 0) ((num_topics,), cur) = relative_unpack('>i', data, cur) for _ in r...
[ "def", "decode_offset_fetch_response", "(", "cls", ",", "data", ")", ":", "(", "(", "correlation_id", ",", ")", ",", "cur", ")", "=", "relative_unpack", "(", "'>i'", ",", "data", ",", "0", ")", "(", "(", "num_topics", ",", ")", ",", "cur", ")", "=", ...
Decode bytes to an OffsetFetchResponse Arguments: data: bytes to decode
[ "Decode", "bytes", "to", "an", "OffsetFetchResponse" ]
python
train
37.545455
aouyar/PyMunin
pymunin/__init__.py
https://github.com/aouyar/PyMunin/blob/4f58a64b6b37c85a84cc7e1e07aafaa0321b249d/pymunin/__init__.py#L289-L306
def _formatVals(self, val_list): """Formats value list from Munin Graph and returns multi-line value entries for the plugin fetch cycle. @param val_list: List of name-value pairs. @return: Multi-line text. """ vals = [] for (name, val) i...
[ "def", "_formatVals", "(", "self", ",", "val_list", ")", ":", "vals", "=", "[", "]", "for", "(", "name", ",", "val", ")", "in", "val_list", ":", "if", "val", "is", "not", "None", ":", "if", "isinstance", "(", "val", ",", "float", ")", ":", "vals"...
Formats value list from Munin Graph and returns multi-line value entries for the plugin fetch cycle. @param val_list: List of name-value pairs. @return: Multi-line text.
[ "Formats", "value", "list", "from", "Munin", "Graph", "and", "returns", "multi", "-", "line", "value", "entries", "for", "the", "plugin", "fetch", "cycle", "." ]
python
train
35.222222
Geotab/mygeotab-python
mygeotab/api.py
https://github.com/Geotab/mygeotab-python/blob/baa678e7df90bdd15f5dc55c1374b5c048791a94/mygeotab/api.py#L261-L267
def get_param(self): """A simple representation of the credentials object for passing into the API.authenticate() server call. :return: The simple credentials object for use by API.authenticate(). :rtype: dict """ return dict(userName=self.username, sessionId=self.session_id, da...
[ "def", "get_param", "(", "self", ")", ":", "return", "dict", "(", "userName", "=", "self", ".", "username", ",", "sessionId", "=", "self", ".", "session_id", ",", "database", "=", "self", ".", "database", ")" ]
A simple representation of the credentials object for passing into the API.authenticate() server call. :return: The simple credentials object for use by API.authenticate(). :rtype: dict
[ "A", "simple", "representation", "of", "the", "credentials", "object", "for", "passing", "into", "the", "API", ".", "authenticate", "()", "server", "call", "." ]
python
train
47.857143
funilrys/PyFunceble
PyFunceble/clean.py
https://github.com/funilrys/PyFunceble/blob/cdf69cbde120199171f7158e1c33635753e6e2f5/PyFunceble/clean.py#L128-L170
def file_to_delete(cls): """ Return the list of file to delete. """ # We initiate the directory we have to look for. directory = PyFunceble.OUTPUT_DIRECTORY + PyFunceble.OUTPUTS["parent_directory"] if not directory.endswith(PyFunceble.directory_separator): # pragma: no...
[ "def", "file_to_delete", "(", "cls", ")", ":", "# We initiate the directory we have to look for.", "directory", "=", "PyFunceble", ".", "OUTPUT_DIRECTORY", "+", "PyFunceble", ".", "OUTPUTS", "[", "\"parent_directory\"", "]", "if", "not", "directory", ".", "endswith", ...
Return the list of file to delete.
[ "Return", "the", "list", "of", "file", "to", "delete", "." ]
python
test
42.348837
fhcrc/seqmagick
seqmagick/subcommands/common.py
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/common.py#L181-L193
def positive_value(target_type): """ Wraps target_type in a function that requires the parsed argument be >= 0 """ def inner(string): value = target_type(string) if not value >= 0: raise argparse.ArgumentTypeError("Invalid positive number: " + string) ...
[ "def", "positive_value", "(", "target_type", ")", ":", "def", "inner", "(", "string", ")", ":", "value", "=", "target_type", "(", "string", ")", "if", "not", "value", ">=", "0", ":", "raise", "argparse", ".", "ArgumentTypeError", "(", "\"Invalid positive num...
Wraps target_type in a function that requires the parsed argument be >= 0
[ "Wraps", "target_type", "in", "a", "function", "that", "requires", "the", "parsed", "argument", "be", ">", "=", "0" ]
python
train
26.615385
uzumaxy/pyvalid
pyvalid/__accepts.py
https://github.com/uzumaxy/pyvalid/blob/74a1a64df1cc77cac55f12f0fe0f52292c6ae479/pyvalid/__accepts.py#L147-L155
def __ordinal(self, num): """Returns the ordinal number of a given integer, as a string. eg. 1 -> 1st, 2 -> 2nd, 3 -> 3rd, etc. """ if 10 <= num % 100 < 20: return str(num) + 'th' else: ord_info = {1: 'st', 2: 'nd', 3: 'rd'}.get(num % 10, 'th') ...
[ "def", "__ordinal", "(", "self", ",", "num", ")", ":", "if", "10", "<=", "num", "%", "100", "<", "20", ":", "return", "str", "(", "num", ")", "+", "'th'", "else", ":", "ord_info", "=", "{", "1", ":", "'st'", ",", "2", ":", "'nd'", ",", "3", ...
Returns the ordinal number of a given integer, as a string. eg. 1 -> 1st, 2 -> 2nd, 3 -> 3rd, etc.
[ "Returns", "the", "ordinal", "number", "of", "a", "given", "integer", "as", "a", "string", ".", "eg", ".", "1", "-", ">", "1st", "2", "-", ">", "2nd", "3", "-", ">", "3rd", "etc", "." ]
python
train
38.666667
google/transitfeed
transitfeed/schedule.py
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/schedule.py#L221-L232
def GetDefaultServicePeriod(self): """Return the default ServicePeriod. If no default ServicePeriod has been set select the default depending on how many ServicePeriod objects are in the Schedule. If there are 0 make a new ServicePeriod the default, if there is 1 it becomes the default, if there is more...
[ "def", "GetDefaultServicePeriod", "(", "self", ")", ":", "if", "not", "self", ".", "_default_service_period", ":", "if", "len", "(", "self", ".", "service_periods", ")", "==", "0", ":", "self", ".", "NewDefaultServicePeriod", "(", ")", "elif", "len", "(", ...
Return the default ServicePeriod. If no default ServicePeriod has been set select the default depending on how many ServicePeriod objects are in the Schedule. If there are 0 make a new ServicePeriod the default, if there is 1 it becomes the default, if there is more than 1 then return None.
[ "Return", "the", "default", "ServicePeriod", ".", "If", "no", "default", "ServicePeriod", "has", "been", "set", "select", "the", "default", "depending", "on", "how", "many", "ServicePeriod", "objects", "are", "in", "the", "Schedule", ".", "If", "there", "are",...
python
train
51.5
larryng/narwal
narwal/things.py
https://github.com/larryng/narwal/blob/58c409a475c8ed865579a61d7010162ed8cef597/narwal/things.py#L435-L440
def top(self, limit=None): """GETs top links from this subreddit. Calls :meth:`narwal.Reddit.top`. :param limit: max number of links to return """ return self._reddit.top(self.display_name, limit=limit)
[ "def", "top", "(", "self", ",", "limit", "=", "None", ")", ":", "return", "self", ".", "_reddit", ".", "top", "(", "self", ".", "display_name", ",", "limit", "=", "limit", ")" ]
GETs top links from this subreddit. Calls :meth:`narwal.Reddit.top`. :param limit: max number of links to return
[ "GETs", "top", "links", "from", "this", "subreddit", ".", "Calls", ":", "meth", ":", "narwal", ".", "Reddit", ".", "top", ".", ":", "param", "limit", ":", "max", "number", "of", "links", "to", "return" ]
python
train
39.833333
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/utils/frame.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/utils/frame.py#L88-L93
def extract_module_locals(depth=0): """Returns (module, locals) of the funciton `depth` frames away from the caller""" f = sys._getframe(depth + 1) global_ns = f.f_globals module = sys.modules[global_ns['__name__']] return (module, f.f_locals)
[ "def", "extract_module_locals", "(", "depth", "=", "0", ")", ":", "f", "=", "sys", ".", "_getframe", "(", "depth", "+", "1", ")", "global_ns", "=", "f", ".", "f_globals", "module", "=", "sys", ".", "modules", "[", "global_ns", "[", "'__name__'", "]", ...
Returns (module, locals) of the funciton `depth` frames away from the caller
[ "Returns", "(", "module", "locals", ")", "of", "the", "funciton", "depth", "frames", "away", "from", "the", "caller" ]
python
test
43
nathankw/pulsarpy
pulsarpy/models.py
https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L413-L421
def delete(self): """Deletes the record. """ res = requests.delete(url=self.record_url, headers=HEADERS, verify=False) #self.write_response_html_to_file(res,"bob_delete.html") if res.status_code == 204: #No content. Can't render json: return {} ret...
[ "def", "delete", "(", "self", ")", ":", "res", "=", "requests", ".", "delete", "(", "url", "=", "self", ".", "record_url", ",", "headers", "=", "HEADERS", ",", "verify", "=", "False", ")", "#self.write_response_html_to_file(res,\"bob_delete.html\")", "if", "re...
Deletes the record.
[ "Deletes", "the", "record", "." ]
python
train
36.222222
saltstack/salt
salt/runners/cache.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/cache.py#L125-L145
def _clear_cache(tgt=None, tgt_type='glob', clear_pillar_flag=False, clear_grains_flag=False, clear_mine_flag=False, clear_mine_func_flag=None): ''' Clear the cached data/files for the targeted minions. ''' if tgt is No...
[ "def", "_clear_cache", "(", "tgt", "=", "None", ",", "tgt_type", "=", "'glob'", ",", "clear_pillar_flag", "=", "False", ",", "clear_grains_flag", "=", "False", ",", "clear_mine_flag", "=", "False", ",", "clear_mine_func_flag", "=", "None", ")", ":", "if", "t...
Clear the cached data/files for the targeted minions.
[ "Clear", "the", "cached", "data", "/", "files", "for", "the", "targeted", "minions", "." ]
python
train
51.809524
todddeluca/python-vagrant
vagrant/__init__.py
https://github.com/todddeluca/python-vagrant/blob/83b26f9337b1f2cb6314210923bbd189e7c9199e/vagrant/__init__.py#L1056-L1073
def _parse_vagrant_sandbox_status(self, vagrant_output): ''' Returns the status of the sandbox mode given output from 'vagrant sandbox status'. ''' # typical output # [default] - snapshot mode is off # or # [default] - machine not created # if the ...
[ "def", "_parse_vagrant_sandbox_status", "(", "self", ",", "vagrant_output", ")", ":", "# typical output", "# [default] - snapshot mode is off", "# or", "# [default] - machine not created", "# if the box VM is down", "tokens", "=", "[", "token", ".", "strip", "(", ")", "for"...
Returns the status of the sandbox mode given output from 'vagrant sandbox status'.
[ "Returns", "the", "status", "of", "the", "sandbox", "mode", "given", "output", "from", "vagrant", "sandbox", "status", "." ]
python
train
36.5
aliyun/aliyun-log-python-sdk
aliyun/log/logclient.py
https://github.com/aliyun/aliyun-log-python-sdk/blob/ac383db0a16abf1e5ef7df36074374184b43516e/aliyun/log/logclient.py#L1821-L1840
def get_machine_group_applied_configs(self, project_name, group_name): """ get the logtail config names applied in a machine group Unsuccessful opertaion will cause an LogException. :type project_name: string :param project_name: the Project name :type group_name: strin...
[ "def", "get_machine_group_applied_configs", "(", "self", ",", "project_name", ",", "group_name", ")", ":", "headers", "=", "{", "}", "params", "=", "{", "}", "resource", "=", "\"/machinegroups/\"", "+", "group_name", "+", "\"/configs\"", "(", "resp", ",", "hea...
get the logtail config names applied in a machine group Unsuccessful opertaion will cause an LogException. :type project_name: string :param project_name: the Project name :type group_name: string :param group_name: the group name list :return: GetMachineGrou...
[ "get", "the", "logtail", "config", "names", "applied", "in", "a", "machine", "group", "Unsuccessful", "opertaion", "will", "cause", "an", "LogException", ".", ":", "type", "project_name", ":", "string", ":", "param", "project_name", ":", "the", "Project", "nam...
python
train
36.35
cytoscape/py2cytoscape
py2cytoscape/cyrest/base.py
https://github.com/cytoscape/py2cytoscape/blob/dd34de8d028f512314d0057168df7fef7c5d5195/py2cytoscape/cyrest/base.py#L71-L188
def api(namespace=None, command="", PARAMS={}, body=None, host=HOST, port=str(PORT), version=VERSION, method="POST", verbose=VERBOSE, url=None, parse_params=True): """ General function for interacting with Cytoscape API. :param namespace: namespace where the request should be executed. eg. "string" :pa...
[ "def", "api", "(", "namespace", "=", "None", ",", "command", "=", "\"\"", ",", "PARAMS", "=", "{", "}", ",", "body", "=", "None", ",", "host", "=", "HOST", ",", "port", "=", "str", "(", "PORT", ")", ",", "version", "=", "VERSION", ",", "method", ...
General function for interacting with Cytoscape API. :param namespace: namespace where the request should be executed. eg. "string" :param commnand: command to execute. eg. "protein query" :param PARAMs: a dictionary with the parameters. Check your swagger normaly running on http://localhost:1234/v1/sw...
[ "General", "function", "for", "interacting", "with", "Cytoscape", "API", "." ]
python
train
31.881356
BetterWorks/django-bleachfields
bleachfields/bleachfield.py
https://github.com/BetterWorks/django-bleachfields/blob/6b49aad6daa8c1357af31a2f7941352561d04cd6/bleachfields/bleachfield.py#L26-L34
def clean_text(self, text): '''Clean text using bleach.''' if text is None: return '' text = re.sub(ILLEGAL_CHARACTERS_RE, '', text) if '<' in text or '&lt' in text: text = clean(text, tags=self.tags, strip=self.strip) return unescape(text)
[ "def", "clean_text", "(", "self", ",", "text", ")", ":", "if", "text", "is", "None", ":", "return", "''", "text", "=", "re", ".", "sub", "(", "ILLEGAL_CHARACTERS_RE", ",", "''", ",", "text", ")", "if", "'<'", "in", "text", "or", "'&lt'", "in", "tex...
Clean text using bleach.
[ "Clean", "text", "using", "bleach", "." ]
python
train
33
FreshXOpenSource/wallaby-frontend-qt
wallaby/frontends/qt/reactor/threadedselect.py
https://github.com/FreshXOpenSource/wallaby-frontend-qt/blob/eee70d0ec4ce34827f62a1654e28dbff8a8afb1a/wallaby/frontends/qt/reactor/threadedselect.py#L315-L319
def addWriter(self, writer): """Add a FileDescriptor for notification of data available to write. """ self._sendToThread(self.writes.__setitem__, writer, 1) self.wakeUp()
[ "def", "addWriter", "(", "self", ",", "writer", ")", ":", "self", ".", "_sendToThread", "(", "self", ".", "writes", ".", "__setitem__", ",", "writer", ",", "1", ")", "self", ".", "wakeUp", "(", ")" ]
Add a FileDescriptor for notification of data available to write.
[ "Add", "a", "FileDescriptor", "for", "notification", "of", "data", "available", "to", "write", "." ]
python
train
39.6
RedHatInsights/insights-core
insights/client/utilities.py
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/utilities.py#L66-L80
def write_unregistered_file(date=None): """ Write .unregistered out to disk """ delete_registered_file() if date is None: date = get_time() for f in constants.unregistered_files: if os.path.lexists(f): if os.path.islink(f): # kill symlinks and regenera...
[ "def", "write_unregistered_file", "(", "date", "=", "None", ")", ":", "delete_registered_file", "(", ")", "if", "date", "is", "None", ":", "date", "=", "get_time", "(", ")", "for", "f", "in", "constants", ".", "unregistered_files", ":", "if", "os", ".", ...
Write .unregistered out to disk
[ "Write", ".", "unregistered", "out", "to", "disk" ]
python
train
30.066667
inasafe/inasafe
safe/gis/vector/from_counts_to_ratios.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/from_counts_to_ratios.py#L26-L105
def from_counts_to_ratios(layer): """Transform counts to ratios. Formula: ratio = subset count / total count :param layer: The vector layer. :type layer: QgsVectorLayer :return: The layer with new ratios. :rtype: QgsVectorLayer .. versionadded:: 4.0 """ output_layer_name = recomp...
[ "def", "from_counts_to_ratios", "(", "layer", ")", ":", "output_layer_name", "=", "recompute_counts_steps", "[", "'output_layer_name'", "]", "exposure", "=", "definition", "(", "layer", ".", "keywords", "[", "'exposure'", "]", ")", "inasafe_fields", "=", "layer", ...
Transform counts to ratios. Formula: ratio = subset count / total count :param layer: The vector layer. :type layer: QgsVectorLayer :return: The layer with new ratios. :rtype: QgsVectorLayer .. versionadded:: 4.0
[ "Transform", "counts", "to", "ratios", "." ]
python
train
37.65
maxfischer2781/include
include/encoded/import_hook.py
https://github.com/maxfischer2781/include/blob/d8b0404f4996b6abcd39fdebf282b31fad8bb6f5/include/encoded/import_hook.py#L24-L30
def uri2module(self, uri): """Convert an unencoded source uri to an encoded module name""" # uri is the source code of the module compressed = zlib.compress(uri) encoded = base64.b64encode(compressed, b'+&') encoded_str = encoded.decode('ASCII') return super(EncodedModule...
[ "def", "uri2module", "(", "self", ",", "uri", ")", ":", "# uri is the source code of the module", "compressed", "=", "zlib", ".", "compress", "(", "uri", ")", "encoded", "=", "base64", ".", "b64encode", "(", "compressed", ",", "b'+&'", ")", "encoded_str", "=",...
Convert an unencoded source uri to an encoded module name
[ "Convert", "an", "unencoded", "source", "uri", "to", "an", "encoded", "module", "name" ]
python
train
50.142857
BlueBrain/NeuroM
neurom/view/view.py
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/view/view.py#L115-L158
def plot_soma(ax, soma, plane='xy', soma_outline=True, linewidth=_LINEWIDTH, color=None, alpha=_ALPHA): '''Generates a 2d figure of the soma. Args: ax(matplotlib axes): on what to plot soma(neurom.core.Soma): plotted soma plane(str): Any pair of...
[ "def", "plot_soma", "(", "ax", ",", "soma", ",", "plane", "=", "'xy'", ",", "soma_outline", "=", "True", ",", "linewidth", "=", "_LINEWIDTH", ",", "color", "=", "None", ",", "alpha", "=", "_ALPHA", ")", ":", "plane0", ",", "plane1", "=", "_plane2col", ...
Generates a 2d figure of the soma. Args: ax(matplotlib axes): on what to plot soma(neurom.core.Soma): plotted soma plane(str): Any pair of 'xyz' diameter_scale(float): Scale factor multiplied with segment diameters before plotting linewidth(float): all segments are plotted w...
[ "Generates", "a", "2d", "figure", "of", "the", "soma", "." ]
python
train
45.363636
poldracklab/niworkflows
niworkflows/interfaces/mni.py
https://github.com/poldracklab/niworkflows/blob/254f4b4fcc5e6ecb29d2f4602a30786b913ecce5/niworkflows/interfaces/mni.py#L436-L502
def create_cfm(in_file, lesion_mask=None, global_mask=True, out_path=None): """ Create a mask to constrain registration. Parameters ---------- in_file : str Path to an existing image (usually a mask). If global_mask = True, this is used as a size/dimension reference. out_path : ...
[ "def", "create_cfm", "(", "in_file", ",", "lesion_mask", "=", "None", ",", "global_mask", "=", "True", ",", "out_path", "=", "None", ")", ":", "import", "os", "import", "numpy", "as", "np", "import", "nibabel", "as", "nb", "from", "nipype", ".", "utils",...
Create a mask to constrain registration. Parameters ---------- in_file : str Path to an existing image (usually a mask). If global_mask = True, this is used as a size/dimension reference. out_path : str Path/filename for the new cost function mask. lesion_mask : str, optiona...
[ "Create", "a", "mask", "to", "constrain", "registration", "." ]
python
train
33.343284
yandex/yandex-tank
yandextank/stepper/util.py
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/util.py#L18-L49
def parse_duration(duration): ''' Parse duration string, such as '3h2m3s' into milliseconds >>> parse_duration('3h2m3s') 10923000 >>> parse_duration('0.3s') 300 >>> parse_duration('5') 5000 ''' _re_token = re.compile("([0-9.]+)([dhms]?)") def parse_token(time, multiplier)...
[ "def", "parse_duration", "(", "duration", ")", ":", "_re_token", "=", "re", ".", "compile", "(", "\"([0-9.]+)([dhms]?)\"", ")", "def", "parse_token", "(", "time", ",", "multiplier", ")", ":", "multipliers", "=", "{", "'d'", ":", "86400", ",", "'h'", ":", ...
Parse duration string, such as '3h2m3s' into milliseconds >>> parse_duration('3h2m3s') 10923000 >>> parse_duration('0.3s') 300 >>> parse_duration('5') 5000
[ "Parse", "duration", "string", "such", "as", "3h2m3s", "into", "milliseconds" ]
python
test
25.46875
erget/StereoVision
stereovision/calibration.py
https://github.com/erget/StereoVision/blob/1adff45e291362f52188e0fd0211265845a4461a/stereovision/calibration.py#L53-L56
def _copy_calibration(self, calibration): """Copy another ``StereoCalibration`` object's values.""" for key, item in calibration.__dict__.items(): self.__dict__[key] = item
[ "def", "_copy_calibration", "(", "self", ",", "calibration", ")", ":", "for", "key", ",", "item", "in", "calibration", ".", "__dict__", ".", "items", "(", ")", ":", "self", ".", "__dict__", "[", "key", "]", "=", "item" ]
Copy another ``StereoCalibration`` object's values.
[ "Copy", "another", "StereoCalibration", "object", "s", "values", "." ]
python
train
49.25
materialsproject/pymatgen
pymatgen/analysis/chemenv/coordination_environments/coordination_geometry_finder.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/chemenv/coordination_environments/coordination_geometry_finder.py#L1376-L1504
def coordination_geometry_symmetry_measures_separation_plane_optim(self, coordination_geometry, separation_plane_algo, ...
[ "def", "coordination_geometry_symmetry_measures_separation_plane_optim", "(", "self", ",", "coordination_geometry", ",", "separation_plane_algo", ",", "points_perfect", "=", "None", ",", "nb_set", "=", "None", ",", "optimization", "=", "None", ")", ":", "if", "optimizat...
Returns the symmetry measures of the given coordination geometry "coordination_geometry" using separation facets to reduce the complexity of the system. Caller to the refined 2POINTS, 3POINTS and other ... :param coordination_geometry: The coordination geometry to be investigated :return: The sy...
[ "Returns", "the", "symmetry", "measures", "of", "the", "given", "coordination", "geometry", "coordination_geometry", "using", "separation", "facets", "to", "reduce", "the", "complexity", "of", "the", "system", ".", "Caller", "to", "the", "refined", "2POINTS", "3PO...
python
train
56.844961
yougov/solr-doc-manager
mongo_connector/doc_managers/solr_doc_manager.py
https://github.com/yougov/solr-doc-manager/blob/1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd/mongo_connector/doc_managers/solr_doc_manager.py#L112-L165
def _clean_doc(self, doc, namespace, timestamp): """Reformats the given document before insertion into Solr. This method reformats the document in the following ways: - removes extraneous fields that aren't defined in schema.xml - unwinds arrays in order to find and later flatten su...
[ "def", "_clean_doc", "(", "self", ",", "doc", ",", "namespace", ",", "timestamp", ")", ":", "# Translate the _id field to whatever unique key we're using.", "# _id may not exist in the doc, if we retrieved it from Solr", "# as part of update.", "if", "'_id'", "in", "doc", ":", ...
Reformats the given document before insertion into Solr. This method reformats the document in the following ways: - removes extraneous fields that aren't defined in schema.xml - unwinds arrays in order to find and later flatten sub-documents - flattens the document so that there ...
[ "Reformats", "the", "given", "document", "before", "insertion", "into", "Solr", "." ]
python
train
39.314815
peri-source/peri
peri/initializers.py
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/initializers.py#L81-L88
def generate_sphere(radius): """Generates a centered boolean mask of a 3D sphere""" rint = np.ceil(radius).astype('int') t = np.arange(-rint, rint+1, 1) x,y,z = np.meshgrid(t, t, t, indexing='ij') r = np.sqrt(x*x + y*y + z*z) sphere = r < radius return sphere
[ "def", "generate_sphere", "(", "radius", ")", ":", "rint", "=", "np", ".", "ceil", "(", "radius", ")", ".", "astype", "(", "'int'", ")", "t", "=", "np", ".", "arange", "(", "-", "rint", ",", "rint", "+", "1", ",", "1", ")", "x", ",", "y", ","...
Generates a centered boolean mask of a 3D sphere
[ "Generates", "a", "centered", "boolean", "mask", "of", "a", "3D", "sphere" ]
python
valid
35
Microsoft/LightGBM
helpers/parameter_generator.py
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/helpers/parameter_generator.py#L160-L242
def gen_parameter_description(sections, descriptions, params_rst): """Write descriptions of parameters to the documentation file. Parameters ---------- sections : list Names of parameters sections. descriptions : list Structured descriptions of parameters. params_rst : string ...
[ "def", "gen_parameter_description", "(", "sections", ",", "descriptions", ",", "params_rst", ")", ":", "def", "parse_check", "(", "check", ",", "reverse", "=", "False", ")", ":", "\"\"\"Parse the constraint.\n\n Parameters\n ----------\n check : string\n ...
Write descriptions of parameters to the documentation file. Parameters ---------- sections : list Names of parameters sections. descriptions : list Structured descriptions of parameters. params_rst : string Path to the file with parameters documentation.
[ "Write", "descriptions", "of", "parameters", "to", "the", "documentation", "file", "." ]
python
train
43.795181
ska-sa/montblanc
montblanc/util/__init__.py
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/util/__init__.py#L128-L149
def dict_array_bytes(ary, template): """ Return the number of bytes required by an array Arguments --------------- ary : dict Dictionary representation of an array template : dict A dictionary of key-values, used to replace any string values in the array with concrete in...
[ "def", "dict_array_bytes", "(", "ary", ",", "template", ")", ":", "shape", "=", "shape_from_str_tuple", "(", "ary", "[", "'shape'", "]", ",", "template", ")", "dtype", "=", "dtype_from_str", "(", "ary", "[", "'dtype'", "]", ",", "template", ")", "return", ...
Return the number of bytes required by an array Arguments --------------- ary : dict Dictionary representation of an array template : dict A dictionary of key-values, used to replace any string values in the array with concrete integral values Returns ----------...
[ "Return", "the", "number", "of", "bytes", "required", "by", "an", "array" ]
python
train
25.636364
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L465-L544
def conv(name, x, output_channels, filter_size=None, stride=None, logscale_factor=3.0, apply_actnorm=True, conv_init="default", dilations=None): """Convolutional layer with edge bias padding and optional actnorm. If x is 5-dimensional, actnorm is applied independently across every time-step. ...
[ "def", "conv", "(", "name", ",", "x", ",", "output_channels", ",", "filter_size", "=", "None", ",", "stride", "=", "None", ",", "logscale_factor", "=", "3.0", ",", "apply_actnorm", "=", "True", ",", "conv_init", "=", "\"default\"", ",", "dilations", "=", ...
Convolutional layer with edge bias padding and optional actnorm. If x is 5-dimensional, actnorm is applied independently across every time-step. Args: name: variable scope. x: 4-D Tensor or 5-D Tensor of shape NHWC or NTHWC output_channels: Number of output channels. filter_size: list of ints, i...
[ "Convolutional", "layer", "with", "edge", "bias", "padding", "and", "optional", "actnorm", "." ]
python
train
35.9625
benley/butcher
butcher/main.py
https://github.com/benley/butcher/blob/8b18828ea040af56b7835beab5fd03eab23cc9ee/butcher/main.py#L295-L304
def load_buildfile(self, target): """Pull a build file from git.""" log.info('Loading: %s', target) filepath = os.path.join(target.path, app.get_options().buildfile_name) try: repo = self.repo_state.GetRepo(target.repo) return repo.get_file(filepath) excep...
[ "def", "load_buildfile", "(", "self", ",", "target", ")", ":", "log", ".", "info", "(", "'Loading: %s'", ",", "target", ")", "filepath", "=", "os", ".", "path", ".", "join", "(", "target", ".", "path", ",", "app", ".", "get_options", "(", ")", ".", ...
Pull a build file from git.
[ "Pull", "a", "build", "file", "from", "git", "." ]
python
train
44.5
codenerix/django-codenerix-extensions
codenerix_extensions/helpers.py
https://github.com/codenerix/django-codenerix-extensions/blob/e9c1d6f99f3e05833ab103bed2689ec34d64e591/codenerix_extensions/helpers.py#L29-L38
def get_external_model(class_object): """ Given a class (class_object), it locates the related model (throught the codenerix abstract class) """ class_abstract = class_object.CodenerixMeta.abstract if class_abstract is not None: for class_related in class_object._meta.related_objects: ...
[ "def", "get_external_model", "(", "class_object", ")", ":", "class_abstract", "=", "class_object", ".", "CodenerixMeta", ".", "abstract", "if", "class_abstract", "is", "not", "None", ":", "for", "class_related", "in", "class_object", ".", "_meta", ".", "related_ob...
Given a class (class_object), it locates the related model (throught the codenerix abstract class)
[ "Given", "a", "class", "(", "class_object", ")", "it", "locates", "the", "related", "model", "(", "throught", "the", "codenerix", "abstract", "class", ")" ]
python
train
44.3
exosite-labs/pyonep
pyonep/onep.py
https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/onep.py#L221-L238
def _call(self, method, auth, arg, defer, notimeout=False): """Calls the Exosite One Platform RPC API. If `defer` is False, result is a tuple with this structure: (success (boolean), response) Otherwise, the result is just True. notimeout, if True, ignores th...
[ "def", "_call", "(", "self", ",", "method", ",", "auth", ",", "arg", ",", "defer", ",", "notimeout", "=", "False", ")", ":", "if", "defer", ":", "self", ".", "deferred", ".", "add", "(", "auth", ",", "method", ",", "arg", ",", "notimeout", "=", "...
Calls the Exosite One Platform RPC API. If `defer` is False, result is a tuple with this structure: (success (boolean), response) Otherwise, the result is just True. notimeout, if True, ignores the reuseconnection setting, creating a new connection with no...
[ "Calls", "the", "Exosite", "One", "Platform", "RPC", "API", "." ]
python
train
36
openspending/ckanext-budgets
ckanext/budgets/plugin.py
https://github.com/openspending/ckanext-budgets/blob/07dde5a4fdec6b36ceb812b70f0c31cdecb40cfc/ckanext/budgets/plugin.py#L38-L89
def configure(self, config): """ Initialize the plugin. This creates a data object which holds a BudgetDataPackage parser which operates based on a specification which is either provided in the config via: ``ckan.budgets.specification`` or the included version. """ ...
[ "def", "configure", "(", "self", ",", "config", ")", ":", "specification", "=", "config", ".", "get", "(", "'ckan.budgets.specification'", ",", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'data'", ...
Initialize the plugin. This creates a data object which holds a BudgetDataPackage parser which operates based on a specification which is either provided in the config via: ``ckan.budgets.specification`` or the included version.
[ "Initialize", "the", "plugin", ".", "This", "creates", "a", "data", "object", "which", "holds", "a", "BudgetDataPackage", "parser", "which", "operates", "based", "on", "a", "specification", "which", "is", "either", "provided", "in", "the", "config", "via", ":"...
python
train
40.711538
MillionIntegrals/vel
vel/rl/modules/action_head.py
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/modules/action_head.py#L35-L43
def sample(self, params, argmax_sampling=False): """ Sample from a probability space of all actions """ means = params[:, :, 0] log_std = params[:, :, 1] if argmax_sampling: return means else: return torch.randn_like(means) * torch.exp(log_std) + means
[ "def", "sample", "(", "self", ",", "params", ",", "argmax_sampling", "=", "False", ")", ":", "means", "=", "params", "[", ":", ",", ":", ",", "0", "]", "log_std", "=", "params", "[", ":", ",", ":", ",", "1", "]", "if", "argmax_sampling", ":", "re...
Sample from a probability space of all actions
[ "Sample", "from", "a", "probability", "space", "of", "all", "actions" ]
python
train
34.333333
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1004-L1021
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ options = super(Del...
[ "def", "fix_config", "(", "self", ",", "options", ")", ":", "options", "=", "super", "(", "DeleteFile", ",", "self", ")", ".", "fix_config", "(", "options", ")", "opt", "=", "\"regexp\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt",...
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
[ "Fixes", "the", "options", "if", "necessary", ".", "I", ".", "e", ".", "it", "adds", "all", "required", "elements", "to", "the", "dictionary", "." ]
python
train
31.722222
MacHu-GWU/superjson-project
superjson/_superjson.py
https://github.com/MacHu-GWU/superjson-project/blob/782ca4b2edbd4b4018b8cedee42eeae7c921b917/superjson/_superjson.py#L452-L456
def dump_set(self, obj, class_name=set_class_name): """ ``set`` dumper. """ return {"$" + class_name: [self._json_convert(item) for item in obj]}
[ "def", "dump_set", "(", "self", ",", "obj", ",", "class_name", "=", "set_class_name", ")", ":", "return", "{", "\"$\"", "+", "class_name", ":", "[", "self", ".", "_json_convert", "(", "item", ")", "for", "item", "in", "obj", "]", "}" ]
``set`` dumper.
[ "set", "dumper", "." ]
python
valid
34.6
bitlabstudio/django-development-fabfile
development_fabfile/fabfile/local.py
https://github.com/bitlabstudio/django-development-fabfile/blob/a135c6eb5bdd0b496a7eccfd271aca558dd99243/development_fabfile/fabfile/local.py#L179-L206
def syntax_check(): """Runs flake8 against the codebase.""" with fab_settings(warn_only=True): for file_type in settings.SYNTAX_CHECK: needs_to_abort = False # because egrep fails with exit code 1, we need to allow this as # a successful exit code in our env ...
[ "def", "syntax_check", "(", ")", ":", "with", "fab_settings", "(", "warn_only", "=", "True", ")", ":", "for", "file_type", "in", "settings", ".", "SYNTAX_CHECK", ":", "needs_to_abort", "=", "False", "# because egrep fails with exit code 1, we need to allow this as", "...
Runs flake8 against the codebase.
[ "Runs", "flake8", "against", "the", "codebase", "." ]
python
train
44.071429
cloud-custodian/cloud-custodian
tools/c7n_salactus/c7n_salactus/cli.py
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/cli.py#L533-L582
def watch(limit): """watch scan rates across the cluster""" period = 5.0 prev = db.db() prev_totals = None while True: click.clear() time.sleep(period) cur = db.db() cur.data['gkrate'] = {} progress = [] prev_buckets = {b.bucket_id: b for b in prev.bu...
[ "def", "watch", "(", "limit", ")", ":", "period", "=", "5.0", "prev", "=", "db", ".", "db", "(", ")", "prev_totals", "=", "None", "while", "True", ":", "click", ".", "clear", "(", ")", "time", ".", "sleep", "(", "period", ")", "cur", "=", "db", ...
watch scan rates across the cluster
[ "watch", "scan", "rates", "across", "the", "cluster" ]
python
train
29.9
rbccps-iisc/ideam-python-sdk
ideam/entity.py
https://github.com/rbccps-iisc/ideam-python-sdk/blob/fd1fe46f1fbce9b90f4c384b8404522f9dcc1c98/ideam/entity.py#L246-L270
async def asynchronously_get_data(self, url): """ Asynchronously get data from Chunked transfer encoding of https://smartcity.rbccps.org/api/0.1.0/subscribe. (Only this function requires Python 3. Rest of the functions can be run in python2. Args: url (string): url to subscribe ...
[ "async", "def", "asynchronously_get_data", "(", "self", ",", "url", ")", ":", "headers", "=", "{", "\"apikey\"", ":", "self", ".", "entity_api_key", "}", "try", ":", "async", "with", "aiohttp", ".", "ClientSession", "(", "connector", "=", "aiohttp", ".", "...
Asynchronously get data from Chunked transfer encoding of https://smartcity.rbccps.org/api/0.1.0/subscribe. (Only this function requires Python 3. Rest of the functions can be run in python2. Args: url (string): url to subscribe
[ "Asynchronously", "get", "data", "from", "Chunked", "transfer", "encoding", "of", "https", ":", "//", "smartcity", ".", "rbccps", ".", "org", "/", "api", "/", "0", ".", "1", ".", "0", "/", "subscribe", ".", "(", "Only", "this", "function", "requires", ...
python
train
57.32
metric-learn/metric-learn
metric_learn/rca.py
https://github.com/metric-learn/metric-learn/blob/d945df1342c69012608bb70b92520392a0853de6/metric_learn/rca.py#L136-L139
def _inv_sqrtm(x): '''Computes x^(-1/2)''' vals, vecs = np.linalg.eigh(x) return (vecs / np.sqrt(vals)).dot(vecs.T)
[ "def", "_inv_sqrtm", "(", "x", ")", ":", "vals", ",", "vecs", "=", "np", ".", "linalg", ".", "eigh", "(", "x", ")", "return", "(", "vecs", "/", "np", ".", "sqrt", "(", "vals", ")", ")", ".", "dot", "(", "vecs", ".", "T", ")" ]
Computes x^(-1/2)
[ "Computes", "x^", "(", "-", "1", "/", "2", ")" ]
python
train
29.5
zxylvlp/PingPHP
pingphp/grammar.py
https://github.com/zxylvlp/PingPHP/blob/2e9a5f1ef4b5b13310e3f8ff350fa91032357bc5/pingphp/grammar.py#L408-L416
def p_Body(p): ''' Body : Line | Body Line ''' if not isinstance(p[1], Body): p[0] = Body(None, p[1]) else: p[0] = Body(p[1], p[2])
[ "def", "p_Body", "(", "p", ")", ":", "if", "not", "isinstance", "(", "p", "[", "1", "]", ",", "Body", ")", ":", "p", "[", "0", "]", "=", "Body", "(", "None", ",", "p", "[", "1", "]", ")", "else", ":", "p", "[", "0", "]", "=", "Body", "(...
Body : Line | Body Line
[ "Body", ":", "Line", "|", "Body", "Line" ]
python
train
18.666667
shoebot/shoebot
shoebot/data/typography.py
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/typography.py#L55-L68
def pangocairo_create_context(cr): """ If python-gi-cairo is not installed, using PangoCairo.create_context dies with an unhelpful KeyError, check for that and output somethig useful. """ # TODO move this to core.backend try: return PangoCairo.create_context(cr) except KeyError a...
[ "def", "pangocairo_create_context", "(", "cr", ")", ":", "# TODO move this to core.backend", "try", ":", "return", "PangoCairo", ".", "create_context", "(", "cr", ")", "except", "KeyError", "as", "e", ":", "if", "e", ".", "args", "==", "(", "'could not find fore...
If python-gi-cairo is not installed, using PangoCairo.create_context dies with an unhelpful KeyError, check for that and output somethig useful.
[ "If", "python", "-", "gi", "-", "cairo", "is", "not", "installed", "using", "PangoCairo", ".", "create_context", "dies", "with", "an", "unhelpful", "KeyError", "check", "for", "that", "and", "output", "somethig", "useful", "." ]
python
valid
36.357143
mental32/spotify.py
spotify/http.py
https://github.com/mental32/spotify.py/blob/bb296cac7c3dd289908906b7069bd80f43950515/spotify/http.py#L286-L295
def artist_related_artists(self, spotify_id): """Get related artists for an artist by their ID. Parameters ---------- spotify_id : str The spotify_id to search by. """ route = Route('GET', '/artists/{spotify_id}/related-artists', spotify_id=spotify_id) ...
[ "def", "artist_related_artists", "(", "self", ",", "spotify_id", ")", ":", "route", "=", "Route", "(", "'GET'", ",", "'/artists/{spotify_id}/related-artists'", ",", "spotify_id", "=", "spotify_id", ")", "return", "self", ".", "request", "(", "route", ")" ]
Get related artists for an artist by their ID. Parameters ---------- spotify_id : str The spotify_id to search by.
[ "Get", "related", "artists", "for", "an", "artist", "by", "their", "ID", "." ]
python
test
33.9
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L185-L189
def update_font(self): """Update font from Preferences""" font = self.get_plugin_font() for client in self.clients: client.set_font(font)
[ "def", "update_font", "(", "self", ")", ":", "font", "=", "self", ".", "get_plugin_font", "(", ")", "for", "client", "in", "self", ".", "clients", ":", "client", ".", "set_font", "(", "font", ")" ]
Update font from Preferences
[ "Update", "font", "from", "Preferences" ]
python
train
34.6
dead-beef/markovchain
markovchain/image/markov.py
https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/image/markov.py#L228-L279
def _channel(self, width, height, state_sizes, start_level, start_image, dataset): """Generate a channel. Parameters ---------- width : `int` Image width. height : `int` Image height. state_sizes : `list` of (`int` or `None`) ...
[ "def", "_channel", "(", "self", ",", "width", ",", "height", ",", "state_sizes", ",", "start_level", ",", "start_image", ",", "dataset", ")", ":", "ret", "=", "start_image", "for", "level", ",", "state_size", "in", "enumerate", "(", "state_sizes", ",", "st...
Generate a channel. Parameters ---------- width : `int` Image width. height : `int` Image height. state_sizes : `list` of (`int` or `None`) Level state sizes. start_level : `int` Initial level. start_image : `PIL.Im...
[ "Generate", "a", "channel", "." ]
python
train
35.365385
Parsl/parsl
parsl/providers/aws/aws.py
https://github.com/Parsl/parsl/blob/d7afb3bc37f50dcf224ae78637944172edb35dac/parsl/providers/aws/aws.py#L207-L220
def write_state_file(self): """Save information that must persist to a file. We do not want to create a new VPC and new identical security groups, so we save information about them in a file between runs. """ fh = open('awsproviderstate.json', 'w') state = {} sta...
[ "def", "write_state_file", "(", "self", ")", ":", "fh", "=", "open", "(", "'awsproviderstate.json'", ",", "'w'", ")", "state", "=", "{", "}", "state", "[", "'vpcID'", "]", "=", "self", ".", "vpc_id", "state", "[", "'sgID'", "]", "=", "self", ".", "sg...
Save information that must persist to a file. We do not want to create a new VPC and new identical security groups, so we save information about them in a file between runs.
[ "Save", "information", "that", "must", "persist", "to", "a", "file", "." ]
python
valid
39.142857
aio-libs/aioodbc
aioodbc/cursor.py
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L278-L284
def getTypeInfo(self, sql_type): # nopep8 """Executes SQLGetTypeInfo a creates a result set with information about the specified data type or all data types supported by the ODBC driver if not specified. """ fut = self._run_operation(self._impl.getTypeInfo, sql_type) ret...
[ "def", "getTypeInfo", "(", "self", ",", "sql_type", ")", ":", "# nopep8", "fut", "=", "self", ".", "_run_operation", "(", "self", ".", "_impl", ".", "getTypeInfo", ",", "sql_type", ")", "return", "fut" ]
Executes SQLGetTypeInfo a creates a result set with information about the specified data type or all data types supported by the ODBC driver if not specified.
[ "Executes", "SQLGetTypeInfo", "a", "creates", "a", "result", "set", "with", "information", "about", "the", "specified", "data", "type", "or", "all", "data", "types", "supported", "by", "the", "ODBC", "driver", "if", "not", "specified", "." ]
python
train
45.857143
note35/sinon
sinon/lib/stub.py
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/stub.py#L53-L77
def __get_matching_indices(self, args, kwargs, args_list, kwargs_list): """ Args: args: tuple, the arguments inputed by the user kwargs: dictionary, the keyword arguments inputed by the user args_list: list, a list of argument tuples kwargs_list: list, a l...
[ "def", "__get_matching_indices", "(", "self", ",", "args", ",", "kwargs", ",", "args_list", ",", "kwargs_list", ")", ":", "if", "args", "and", "kwargs", ":", "if", "args", "in", "args_list", "and", "kwargs", "in", "kwargs_list", ":", "args_indices", "=", "...
Args: args: tuple, the arguments inputed by the user kwargs: dictionary, the keyword arguments inputed by the user args_list: list, a list of argument tuples kwargs_list: list, a list of keyword argument dictionaries Returns: list, the list of indices ...
[ "Args", ":", "args", ":", "tuple", "the", "arguments", "inputed", "by", "the", "user", "kwargs", ":", "dictionary", "the", "keyword", "arguments", "inputed", "by", "the", "user", "args_list", ":", "list", "a", "list", "of", "argument", "tuples", "kwargs_list...
python
train
47.04
numba/llvmlite
llvmlite/ir/types.py
https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/types.py#L490-L499
def gep(self, i): """ Resolve the type of the i-th element (for getelementptr lookups). *i* needs to be a LLVM constant, so that the type can be determined at compile-time. """ if not isinstance(i.type, IntType): raise TypeError(i.type) return self.el...
[ "def", "gep", "(", "self", ",", "i", ")", ":", "if", "not", "isinstance", "(", "i", ".", "type", ",", "IntType", ")", ":", "raise", "TypeError", "(", "i", ".", "type", ")", "return", "self", ".", "elements", "[", "i", ".", "constant", "]" ]
Resolve the type of the i-th element (for getelementptr lookups). *i* needs to be a LLVM constant, so that the type can be determined at compile-time.
[ "Resolve", "the", "type", "of", "the", "i", "-", "th", "element", "(", "for", "getelementptr", "lookups", ")", "." ]
python
train
32.9
cloudnativelabs/kube-shell
kubeshell/parser.py
https://github.com/cloudnativelabs/kube-shell/blob/adc801d165e87fe62f82b074ec49996954c3fbe8/kubeshell/parser.py#L136-L165
def evalOptions(self, root, parsed, unparsed): """ Evaluate only the options and return flags as suggestions """ logger.debug("parsing options at tree: %s with p:%s, u:%s", root.node, parsed, unparsed) suggestions = dict() token = unparsed.pop().strip() parts = token.partition('...
[ "def", "evalOptions", "(", "self", ",", "root", ",", "parsed", ",", "unparsed", ")", ":", "logger", ".", "debug", "(", "\"parsing options at tree: %s with p:%s, u:%s\"", ",", "root", ".", "node", ",", "parsed", ",", "unparsed", ")", "suggestions", "=", "dict",...
Evaluate only the options and return flags as suggestions
[ "Evaluate", "only", "the", "options", "and", "return", "flags", "as", "suggestions" ]
python
train
49.466667
eandersson/amqpstorm
amqpstorm/channel.py
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/channel.py#L356-L367
def _basic_cancel(self, frame_in): """Handle a Basic Cancel frame. :param specification.Basic.Cancel frame_in: Amqp frame. :return: """ LOGGER.warning( 'Received Basic.Cancel on consumer_tag: %s', try_utf8_decode(frame_in.consumer_tag) ) ...
[ "def", "_basic_cancel", "(", "self", ",", "frame_in", ")", ":", "LOGGER", ".", "warning", "(", "'Received Basic.Cancel on consumer_tag: %s'", ",", "try_utf8_decode", "(", "frame_in", ".", "consumer_tag", ")", ")", "self", ".", "remove_consumer_tag", "(", "frame_in",...
Handle a Basic Cancel frame. :param specification.Basic.Cancel frame_in: Amqp frame. :return:
[ "Handle", "a", "Basic", "Cancel", "frame", "." ]
python
train
29.666667
cathalgarvey/deadlock
deadlock/core.py
https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/core.py#L123-L130
def get_profile(A): "Fail-soft profile getter; if no profile is present assume none and quietly ignore." try: with open(os.path.expanduser(A.profile)) as I: profile = json.load(I) return profile except: return {}
[ "def", "get_profile", "(", "A", ")", ":", "try", ":", "with", "open", "(", "os", ".", "path", ".", "expanduser", "(", "A", ".", "profile", ")", ")", "as", "I", ":", "profile", "=", "json", ".", "load", "(", "I", ")", "return", "profile", "except"...
Fail-soft profile getter; if no profile is present assume none and quietly ignore.
[ "Fail", "-", "soft", "profile", "getter", ";", "if", "no", "profile", "is", "present", "assume", "none", "and", "quietly", "ignore", "." ]
python
train
31.625
mbedmicro/pyOCD
pyocd/coresight/cortex_m.py
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/coresight/cortex_m.py#L478-L490
def init(self): """ Cortex M initialization. The bus must be accessible when this method is called. """ if not self.call_delegate('will_start_debug_core', core=self): if self.halt_on_connect: self.halt() self._read_core_type() self._che...
[ "def", "init", "(", "self", ")", ":", "if", "not", "self", ".", "call_delegate", "(", "'will_start_debug_core'", ",", "core", "=", "self", ")", ":", "if", "self", ".", "halt_on_connect", ":", "self", ".", "halt", "(", ")", "self", ".", "_read_core_type",...
Cortex M initialization. The bus must be accessible when this method is called.
[ "Cortex", "M", "initialization", ".", "The", "bus", "must", "be", "accessible", "when", "this", "method", "is", "called", "." ]
python
train
34.538462
nicolargo/glances
glances/plugins/glances_amps.py
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_amps.py#L45-L67
def update(self): """Update the AMP list.""" # Init new stats stats = self.get_init_value() if self.input_method == 'local': for k, v in iteritems(self.glances_amps.update()): stats.append({'key': k, 'name': v.NAME, ...
[ "def", "update", "(", "self", ")", ":", "# Init new stats", "stats", "=", "self", ".", "get_init_value", "(", ")", "if", "self", ".", "input_method", "==", "'local'", ":", "for", "k", ",", "v", "in", "iteritems", "(", "self", ".", "glances_amps", ".", ...
Update the AMP list.
[ "Update", "the", "AMP", "list", "." ]
python
train
33.565217
grst/geos
geos/kml.py
https://github.com/grst/geos/blob/ea15abcc5d8f86c9051df55e489b7d941b51a638/geos/kml.py#L94-L111
def kml_lod(min_lod_pixels=DEFAULT_MIN_LOD_PIXELS, max_lod_pixels=DEFAULT_MAX_LOD_PIXELS): """ Create the KML LevelOfDetail (LOD) Tag. In a Region, the <minLodPixels> and <maxLodPixels> elements allow you to specify an area of the screen (in square pixels). When your data is projected onto the screen, ...
[ "def", "kml_lod", "(", "min_lod_pixels", "=", "DEFAULT_MIN_LOD_PIXELS", ",", "max_lod_pixels", "=", "DEFAULT_MAX_LOD_PIXELS", ")", ":", "return", "KML", ".", "Lod", "(", "KML", ".", "minLodPixels", "(", "min_lod_pixels", ")", ",", "KML", ".", "maxLodPixels", "("...
Create the KML LevelOfDetail (LOD) Tag. In a Region, the <minLodPixels> and <maxLodPixels> elements allow you to specify an area of the screen (in square pixels). When your data is projected onto the screen, it must occupy an area of the screen that is greater than <minLodPixels> and less than <maxLodP...
[ "Create", "the", "KML", "LevelOfDetail", "(", "LOD", ")", "Tag", "." ]
python
train
45.722222
praekelt/django-ultracache
ultracache/templatetags/ultracache_tags.py
https://github.com/praekelt/django-ultracache/blob/8898f10e50fc8f8d0a4cb7d3fe4d945bf257bd9f/ultracache/templatetags/ultracache_tags.py#L88-L98
def do_ultracache(parser, token): """Based on Django's default cache template tag""" nodelist = parser.parse(("endultracache",)) parser.delete_first_token() tokens = token.split_contents() if len(tokens) < 3: raise TemplateSyntaxError(""%r" tag requires at least 2 arguments." % tokens[0]) ...
[ "def", "do_ultracache", "(", "parser", ",", "token", ")", ":", "nodelist", "=", "parser", ".", "parse", "(", "(", "\"endultracache\"", ",", ")", ")", "parser", ".", "delete_first_token", "(", ")", "tokens", "=", "token", ".", "split_contents", "(", ")", ...
Based on Django's default cache template tag
[ "Based", "on", "Django", "s", "default", "cache", "template", "tag" ]
python
train
45.909091
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/util/bottle3.py
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/util/bottle3.py#L225-L232
def group_re(self): ''' Return a regexp pattern with named groups ''' out = '' for token, data in self.tokens(): if token == 'TXT': out += re.escape(data) elif token == 'VAR': out += '(?P<%s>%s)' % (data[1], data[0]) elif token == 'ANON': out += '(?:%s)' %...
[ "def", "group_re", "(", "self", ")", ":", "out", "=", "''", "for", "token", ",", "data", "in", "self", ".", "tokens", "(", ")", ":", "if", "token", "==", "'TXT'", ":", "out", "+=", "re", ".", "escape", "(", "data", ")", "elif", "token", "==", "...
Return a regexp pattern with named groups
[ "Return", "a", "regexp", "pattern", "with", "named", "groups" ]
python
train
42.125
theislab/scanpy
scanpy/plotting/_utils.py
https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/plotting/_utils.py#L718-L730
def zoom(ax, xy='x', factor=1): """Zoom into axis. Parameters ---------- """ limits = ax.get_xlim() if xy == 'x' else ax.get_ylim() new_limits = (0.5*(limits[0] + limits[1]) + 1./factor * np.array((-0.5, 0.5)) * (limits[1] - limits[0])) if xy == 'x': ax.set_xlim(ne...
[ "def", "zoom", "(", "ax", ",", "xy", "=", "'x'", ",", "factor", "=", "1", ")", ":", "limits", "=", "ax", ".", "get_xlim", "(", ")", "if", "xy", "==", "'x'", "else", "ax", ".", "get_ylim", "(", ")", "new_limits", "=", "(", "0.5", "*", "(", "li...
Zoom into axis. Parameters ----------
[ "Zoom", "into", "axis", "." ]
python
train
27.615385
Azure/blobxfer
blobxfer/operations/upload.py
https://github.com/Azure/blobxfer/blob/3eccbe7530cc6a20ab2d30f9e034b6f021817f34/blobxfer/operations/upload.py#L967-L1100
def _vectorize_and_bind(self, local_path, dest): # type: (Uploader, blobxfer.models.upload.LocalPath, # List[blobxfer.models.azure.StorageEntity]) -> # Tuple[blobxfer.operations.upload.UploadAction, # blobxfer.models.upload.LocalPath, # blobxfer.models...
[ "def", "_vectorize_and_bind", "(", "self", ",", "local_path", ",", "dest", ")", ":", "# type: (Uploader, blobxfer.models.upload.LocalPath,", "# List[blobxfer.models.azure.StorageEntity]) ->", "# Tuple[blobxfer.operations.upload.UploadAction,", "# blobxfer.models.upload...
Vectorize local path to destinations, if necessary, and bind :param Uploader self: this :param blobxfer.models.LocalPath local_path: local path :param list dest: list of destination tuples (sa, ase) :rtype: tuple :return: action, LocalPath, ase
[ "Vectorize", "local", "path", "to", "destinations", "if", "necessary", "and", "bind", ":", "param", "Uploader", "self", ":", "this", ":", "param", "blobxfer", ".", "models", ".", "LocalPath", "local_path", ":", "local", "path", ":", "param", "list", "dest", ...
python
train
49.932836
PmagPy/PmagPy
pmagpy/pmag.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L10755-L10819
def scalc_vgp_df(vgp_df, anti=0, rev=0, cutoff=180., kappa=0, n=0, spin=0, v=0, boot=0, mm97=0, nb=1000): """ Calculates Sf for a dataframe with VGP Lat., and optional Fisher's k, site latitude and N information can be used to correct for within site scatter (McElhinny & McFadden, 1997) Parameters ____...
[ "def", "scalc_vgp_df", "(", "vgp_df", ",", "anti", "=", "0", ",", "rev", "=", "0", ",", "cutoff", "=", "180.", ",", "kappa", "=", "0", ",", "n", "=", "0", ",", "spin", "=", "0", ",", "v", "=", "0", ",", "boot", "=", "0", ",", "mm97", "=", ...
Calculates Sf for a dataframe with VGP Lat., and optional Fisher's k, site latitude and N information can be used to correct for within site scatter (McElhinny & McFadden, 1997) Parameters _________ df : Pandas Dataframe with columns REQUIRED: vgp_lat : VGP latitude ONLY REQUIRED f...
[ "Calculates", "Sf", "for", "a", "dataframe", "with", "VGP", "Lat", ".", "and", "optional", "Fisher", "s", "k", "site", "latitude", "and", "N", "information", "can", "be", "used", "to", "correct", "for", "within", "site", "scatter", "(", "McElhinny", "&", ...
python
train
38.938462
farzadghanei/statsd-metrics
statsdmetrics/client/__init__.py
https://github.com/farzadghanei/statsd-metrics/blob/153ff37b79777f208e49bb9d3fb737ba52b99f98/statsdmetrics/client/__init__.py#L295-L301
def _request(self, data): # type: (str) -> None """Override parent by buffering the metric instead of sending now""" data = bytearray("{}\n".format(data).encode()) self._prepare_batches_for_storage(len(data)) self._batches[-1].extend(data)
[ "def", "_request", "(", "self", ",", "data", ")", ":", "# type: (str) -> None", "data", "=", "bytearray", "(", "\"{}\\n\"", ".", "format", "(", "data", ")", ".", "encode", "(", ")", ")", "self", ".", "_prepare_batches_for_storage", "(", "len", "(", "data",...
Override parent by buffering the metric instead of sending now
[ "Override", "parent", "by", "buffering", "the", "metric", "instead", "of", "sending", "now" ]
python
test
39.142857
angr/claripy
claripy/backends/__init__.py
https://github.com/angr/claripy/blob/4ed61924880af1ea8fb778047d896ec0156412a6/claripy/backends/__init__.py#L720-L728
def identical(self, a, b): """ This should return whether `a` is identical to `b`. Of course, this isn't always clear. True should mean that it is definitely identical. False eans that, conservatively, it might not be. :param a: an AST :param b: another AST """ r...
[ "def", "identical", "(", "self", ",", "a", ",", "b", ")", ":", "return", "self", ".", "_identical", "(", "self", ".", "convert", "(", "a", ")", ",", "self", ".", "convert", "(", "b", ")", ")" ]
This should return whether `a` is identical to `b`. Of course, this isn't always clear. True should mean that it is definitely identical. False eans that, conservatively, it might not be. :param a: an AST :param b: another AST
[ "This", "should", "return", "whether", "a", "is", "identical", "to", "b", ".", "Of", "course", "this", "isn", "t", "always", "clear", ".", "True", "should", "mean", "that", "it", "is", "definitely", "identical", ".", "False", "eans", "that", "conservativel...
python
train
40.777778
kalefranz/auxlib
auxlib/deprecation.py
https://github.com/kalefranz/auxlib/blob/6ff2d6b57d128d0b9ed8f01ad83572e938da064f/auxlib/deprecation.py#L54-L85
def deprecate_module_with_proxy(module_name, module_dict, deprecated_attributes=None): """ Usage: deprecate_module_with_proxy(__name__, locals()) # at bottom of module """ def _ModuleProxy(module, depr): """Return a wrapped object that warns about deprecated accesses""" # http:/...
[ "def", "deprecate_module_with_proxy", "(", "module_name", ",", "module_dict", ",", "deprecated_attributes", "=", "None", ")", ":", "def", "_ModuleProxy", "(", "module", ",", "depr", ")", ":", "\"\"\"Return a wrapped object that warns about deprecated accesses\"\"\"", "# htt...
Usage: deprecate_module_with_proxy(__name__, locals()) # at bottom of module
[ "Usage", ":", "deprecate_module_with_proxy", "(", "__name__", "locals", "()", ")", "#", "at", "bottom", "of", "module" ]
python
train
38.375
guaix-ucm/pyemir
emirdrp/instrument/dtu_configuration.py
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/instrument/dtu_configuration.py#L199-L205
def outdict(self, ndigits=3): """Return dictionary structure rounded to a given precision.""" output = self.__dict__.copy() for item in output: output[item] = round(output[item], ndigits) return output
[ "def", "outdict", "(", "self", ",", "ndigits", "=", "3", ")", ":", "output", "=", "self", ".", "__dict__", ".", "copy", "(", ")", "for", "item", "in", "output", ":", "output", "[", "item", "]", "=", "round", "(", "output", "[", "item", "]", ",", ...
Return dictionary structure rounded to a given precision.
[ "Return", "dictionary", "structure", "rounded", "to", "a", "given", "precision", "." ]
python
train
34.285714
natea/django-deployer
django_deployer/providers.py
https://github.com/natea/django-deployer/blob/5ce7d972db2f8500ec53ad89e7eb312d3360d074/django_deployer/providers.py#L104-L118
def _render_config(cls, dest, template_name, template_args): """ Renders and writes a template_name to a dest given some template_args. This is for platform-specific configurations """ template_args = template_args.copy() # Substitute values here pyversion = tem...
[ "def", "_render_config", "(", "cls", ",", "dest", ",", "template_name", ",", "template_args", ")", ":", "template_args", "=", "template_args", ".", "copy", "(", ")", "# Substitute values here", "pyversion", "=", "template_args", "[", "'pyversion'", "]", "template_...
Renders and writes a template_name to a dest given some template_args. This is for platform-specific configurations
[ "Renders", "and", "writes", "a", "template_name", "to", "a", "dest", "given", "some", "template_args", "." ]
python
train
36.066667
Azure/azure-cli-extensions
src/alias/azext_alias/argument.py
https://github.com/Azure/azure-cli-extensions/blob/3d4854205b0f0d882f688cfa12383d14506c2e35/src/alias/azext_alias/argument.py#L119-L167
def render_template(cmd_derived_from_alias, pos_args_table): """ Render cmd_derived_from_alias as a Jinja template with pos_args_table as the arguments. Args: cmd_derived_from_alias: The string to be injected with positional arguemnts. pos_args_table: The dictionary used to rendered. R...
[ "def", "render_template", "(", "cmd_derived_from_alias", ",", "pos_args_table", ")", ":", "try", ":", "cmd_derived_from_alias", "=", "normalize_placeholders", "(", "cmd_derived_from_alias", ",", "inject_quotes", "=", "True", ")", "template", "=", "jinja", ".", "Templa...
Render cmd_derived_from_alias as a Jinja template with pos_args_table as the arguments. Args: cmd_derived_from_alias: The string to be injected with positional arguemnts. pos_args_table: The dictionary used to rendered. Returns: A processed string with positional arguments injected.
[ "Render", "cmd_derived_from_alias", "as", "a", "Jinja", "template", "with", "pos_args_table", "as", "the", "arguments", "." ]
python
train
45.204082
Erotemic/utool
utool/util_list.py
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L116-L126
def recursive_replace(list_, target, repl=-1): r""" Recursively removes target in all lists and sublists and replaces them with the repl variable """ repl_list = [ recursive_replace(item, target, repl) if isinstance(item, (list, np.ndarray)) else (repl if item == target else item) ...
[ "def", "recursive_replace", "(", "list_", ",", "target", ",", "repl", "=", "-", "1", ")", ":", "repl_list", "=", "[", "recursive_replace", "(", "item", ",", "target", ",", "repl", ")", "if", "isinstance", "(", "item", ",", "(", "list", ",", "np", "."...
r""" Recursively removes target in all lists and sublists and replaces them with the repl variable
[ "r", "Recursively", "removes", "target", "in", "all", "lists", "and", "sublists", "and", "replaces", "them", "with", "the", "repl", "variable" ]
python
train
32.727273
darkfeline/animanager
animanager/sqlite/utils.py
https://github.com/darkfeline/animanager/blob/55d92e4cbdc12aac8ebe302420d2cff3fa9fa148/animanager/sqlite/utils.py#L25-L53
def upsert(db, table, key_cols, update_dict): """Fabled upsert for SQLiteDB. Perform an upsert based on primary key. :param SQLiteDB db: database :param str table: table to upsert into :param str key_cols: name of key columns :param dict update_dict: key-value pairs to upsert """ with...
[ "def", "upsert", "(", "db", ",", "table", ",", "key_cols", ",", "update_dict", ")", ":", "with", "db", ":", "cur", "=", "db", ".", "cursor", "(", ")", "cur", ".", "execute", "(", "'UPDATE {} SET {} WHERE {}'", ".", "format", "(", "table", ",", "','", ...
Fabled upsert for SQLiteDB. Perform an upsert based on primary key. :param SQLiteDB db: database :param str table: table to upsert into :param str key_cols: name of key columns :param dict update_dict: key-value pairs to upsert
[ "Fabled", "upsert", "for", "SQLiteDB", "." ]
python
train
31.413793
quantopian/zipline
zipline/__main__.py
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/__main__.py#L216-L284
def run(ctx, algofile, algotext, define, data_frequency, capital_base, bundle, bundle_timestamp, start, end, output, trading_calendar, print_algo, metrics_set, local_namespace, blotter): """Run a ...
[ "def", "run", "(", "ctx", ",", "algofile", ",", "algotext", ",", "define", ",", "data_frequency", ",", "capital_base", ",", "bundle", ",", "bundle_timestamp", ",", "start", ",", "end", ",", "output", ",", "trading_calendar", ",", "print_algo", ",", "metrics_...
Run a backtest for the given algorithm.
[ "Run", "a", "backtest", "for", "the", "given", "algorithm", "." ]
python
train
28.086957
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2003.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2003.py#L135-L147
def _compute_distance_scaling(self, C, mag, rrup): """ Compute distance scaling term (eq.3, page 319). The distance scaling assumes the near-source effect of local site conditions due to 50% very firm soil and soft rock and 50% firm rock. """ g = C['c5'] + C['c6'] * 0.5 ...
[ "def", "_compute_distance_scaling", "(", "self", ",", "C", ",", "mag", ",", "rrup", ")", ":", "g", "=", "C", "[", "'c5'", "]", "+", "C", "[", "'c6'", "]", "*", "0.5", "+", "C", "[", "'c7'", "]", "*", "0.5", "return", "(", "rrup", "**", "2", "...
Compute distance scaling term (eq.3, page 319). The distance scaling assumes the near-source effect of local site conditions due to 50% very firm soil and soft rock and 50% firm rock.
[ "Compute", "distance", "scaling", "term", "(", "eq", ".", "3", "page", "319", ")", "." ]
python
train
34.538462
nanoporetech/ont_fast5_api
ont_fast5_api/fast5_file.py
https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/fast5_file.py#L315-L346
def get_chain(self, group_name): """ Provides the component and group names for an analysis chain. :param group_name: The group name of the last step in the analysis chain e.g. 'Basecall_1D_000' :returns: A list of component-name/group-name pairs (tuples). This w...
[ "def", "get_chain", "(", "self", ",", "group_name", ")", ":", "self", ".", "assert_open", "(", ")", "endgroup", "=", "'Analyses/{}'", ".", "format", "(", "group_name", ")", "attr", "=", "self", ".", "handle", "[", "endgroup", "]", ".", "attrs", "if", "...
Provides the component and group names for an analysis chain. :param group_name: The group name of the last step in the analysis chain e.g. 'Basecall_1D_000' :returns: A list of component-name/group-name pairs (tuples). This will include each component of the chain, in o...
[ "Provides", "the", "component", "and", "group", "names", "for", "an", "analysis", "chain", ".", ":", "param", "group_name", ":", "The", "group", "name", "of", "the", "last", "step", "in", "the", "analysis", "chain", "e", ".", "g", ".", "Basecall_1D_000", ...
python
train
44.28125
BD2KGenomics/protect
src/protect/expression_profiling/rsem.py
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/expression_profiling/rsem.py#L57-L95
def run_rsem(job, rna_bam, univ_options, rsem_options): """ Run rsem on the input RNA bam. ARGUMENTS :param toil.fileStore.FileID rna_bam: fsID of a transcriptome bam generated by STAR :param dict univ_options: Dict of universal options used by almost all tools :param dict rsem_options: Options...
[ "def", "run_rsem", "(", "job", ",", "rna_bam", ",", "univ_options", ",", "rsem_options", ")", ":", "work_dir", "=", "os", ".", "getcwd", "(", ")", "input_files", "=", "{", "'star_transcriptome.bam'", ":", "rna_bam", ",", "'rsem_index.tar.gz'", ":", "rsem_optio...
Run rsem on the input RNA bam. ARGUMENTS :param toil.fileStore.FileID rna_bam: fsID of a transcriptome bam generated by STAR :param dict univ_options: Dict of universal options used by almost all tools :param dict rsem_options: Options specific to rsem :return: Dict of gene- and isoform-level expre...
[ "Run", "rsem", "on", "the", "input", "RNA", "bam", "." ]
python
train
46.641026
awslabs/aws-sam-cli
samcli/local/docker/utils.py
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/utils.py#L14-L36
def to_posix_path(code_path): """ Change the code_path to be of unix-style if running on windows when supplied with an absolute windows path. Parameters ---------- code_path : str Directory in the host operating system that should be mounted within the container. Returns ------- ...
[ "def", "to_posix_path", "(", "code_path", ")", ":", "return", "re", ".", "sub", "(", "\"^([A-Za-z])+:\"", ",", "lambda", "match", ":", "posixpath", ".", "sep", "+", "match", ".", "group", "(", ")", ".", "replace", "(", "\":\"", ",", "\"\"", ")", ".", ...
Change the code_path to be of unix-style if running on windows when supplied with an absolute windows path. Parameters ---------- code_path : str Directory in the host operating system that should be mounted within the container. Returns ------- str Posix equivalent of absolute ...
[ "Change", "the", "code_path", "to", "be", "of", "unix", "-", "style", "if", "running", "on", "windows", "when", "supplied", "with", "an", "absolute", "windows", "path", "." ]
python
train
35.913043
nerdvegas/rez
src/rez/utils/sourcecode.py
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/sourcecode.py#L52-L61
def include(module_name, *module_names): """Used by functions in package.py to have access to named modules. See the 'package_definition_python_path' config setting for more info. """ def decorated(fn): _add_decorator(fn, "include", nargs=[module_name] + list(module_names)) return fn ...
[ "def", "include", "(", "module_name", ",", "*", "module_names", ")", ":", "def", "decorated", "(", "fn", ")", ":", "_add_decorator", "(", "fn", ",", "\"include\"", ",", "nargs", "=", "[", "module_name", "]", "+", "list", "(", "module_names", ")", ")", ...
Used by functions in package.py to have access to named modules. See the 'package_definition_python_path' config setting for more info.
[ "Used", "by", "functions", "in", "package", ".", "py", "to", "have", "access", "to", "named", "modules", "." ]
python
train
33
pycontribs/pyrax
pyrax/clouddns.py
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddns.py#L301-L322
def _create_body(self, name, emailAddress, ttl=3600, comment=None, subdomains=None, records=None): """ Creates the appropriate dict for creating a new domain. """ if subdomains is None: subdomains = [] if records is None: records = [] b...
[ "def", "_create_body", "(", "self", ",", "name", ",", "emailAddress", ",", "ttl", "=", "3600", ",", "comment", "=", "None", ",", "subdomains", "=", "None", ",", "records", "=", "None", ")", ":", "if", "subdomains", "is", "None", ":", "subdomains", "=",...
Creates the appropriate dict for creating a new domain.
[ "Creates", "the", "appropriate", "dict", "for", "creating", "a", "new", "domain", "." ]
python
train
31.409091
pypa/pipenv
pipenv/patched/notpip/_vendor/pkg_resources/__init__.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/pkg_resources/__init__.py#L1972-L1986
def dist_factory(path_item, entry, only): """ Return a dist_factory for a path_item and entry """ lower = entry.lower() is_meta = any(map(lower.endswith, ('.egg-info', '.dist-info'))) return ( distributions_from_metadata if is_meta else find_distributions if not o...
[ "def", "dist_factory", "(", "path_item", ",", "entry", ",", "only", ")", ":", "lower", "=", "entry", ".", "lower", "(", ")", "is_meta", "=", "any", "(", "map", "(", "lower", ".", "endswith", ",", "(", "'.egg-info'", ",", "'.dist-info'", ")", ")", ")"...
Return a dist_factory for a path_item and entry
[ "Return", "a", "dist_factory", "for", "a", "path_item", "and", "entry" ]
python
train
29.6
tensorflow/tensor2tensor
tensor2tensor/utils/yellowfin.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/yellowfin.py#L389-L396
def _get_lr_tensor(self): """Get lr minimizing the surrogate. Returns: The lr_t. """ lr = tf.squared_difference(1.0, tf.sqrt(self._mu)) / self._h_min return lr
[ "def", "_get_lr_tensor", "(", "self", ")", ":", "lr", "=", "tf", ".", "squared_difference", "(", "1.0", ",", "tf", ".", "sqrt", "(", "self", ".", "_mu", ")", ")", "/", "self", ".", "_h_min", "return", "lr" ]
Get lr minimizing the surrogate. Returns: The lr_t.
[ "Get", "lr", "minimizing", "the", "surrogate", "." ]
python
train
22.375