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
Workiva/furious
furious/async.py
https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/async.py#L515-L521
def context_id(self): """Return this Async's Context Id if it exists.""" if not self._context_id: self._context_id = self._get_context_id() self.update_options(context_id=self._context_id) return self._context_id
[ "def", "context_id", "(", "self", ")", ":", "if", "not", "self", ".", "_context_id", ":", "self", ".", "_context_id", "=", "self", ".", "_get_context_id", "(", ")", "self", ".", "update_options", "(", "context_id", "=", "self", ".", "_context_id", ")", "...
Return this Async's Context Id if it exists.
[ "Return", "this", "Async", "s", "Context", "Id", "if", "it", "exists", "." ]
python
train
36.428571
gem/oq-engine
openquake/risklib/scientific.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/scientific.py#L1306-L1345
def losses_by_period(losses, return_periods, num_events=None, eff_time=None): """ :param losses: array of simulated losses :param return_periods: return periods of interest :param num_events: the number of events (>= to the number of losses) :param eff_time: investigation_time * ses_per_logic_tree_p...
[ "def", "losses_by_period", "(", "losses", ",", "return_periods", ",", "num_events", "=", "None", ",", "eff_time", "=", "None", ")", ":", "if", "len", "(", "losses", ")", "==", "0", ":", "# zero-curve", "return", "numpy", ".", "zeros", "(", "len", "(", ...
:param losses: array of simulated losses :param return_periods: return periods of interest :param num_events: the number of events (>= to the number of losses) :param eff_time: investigation_time * ses_per_logic_tree_path :returns: interpolated losses for the return periods, possibly with NaN NB: t...
[ ":", "param", "losses", ":", "array", "of", "simulated", "losses", ":", "param", "return_periods", ":", "return", "periods", "of", "interest", ":", "param", "num_events", ":", "the", "number", "of", "events", "(", ">", "=", "to", "the", "number", "of", "...
python
train
45.4
gem/oq-engine
openquake/commands/plot_memory.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/plot_memory.py#L22-L38
def make_figure(plots): """ :param plots: list of pairs (task_name, memory array) """ # NB: matplotlib is imported inside since it is a costly import import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.grid(True) ax.set_xlabel('tasks') ax.set_ylabel('GB') start = 0 f...
[ "def", "make_figure", "(", "plots", ")", ":", "# NB: matplotlib is imported inside since it is a costly import", "import", "matplotlib", ".", "pyplot", "as", "plt", "fig", ",", "ax", "=", "plt", ".", "subplots", "(", ")", "ax", ".", "grid", "(", "True", ")", "...
:param plots: list of pairs (task_name, memory array)
[ ":", "param", "plots", ":", "list", "of", "pairs", "(", "task_name", "memory", "array", ")" ]
python
train
26.941176
mitsei/dlkit
dlkit/json_/cataloging/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L379-L403
def get_catalogs_by_query(self, catalog_query): """Gets a list of ``Catalogs`` matching the given catalog query. arg: catalog_query (osid.cataloging.CatalogQuery): the catalog query return: (osid.cataloging.CatalogList) - the returned ``CatalogList`` r...
[ "def", "get_catalogs_by_query", "(", "self", ",", "catalog_query", ")", ":", "# Implemented from template for", "# osid.resource.BinQuerySession.get_bins_by_query_template", "if", "self", ".", "_catalog_session", "is", "not", "None", ":", "return", "self", ".", "_catalog_se...
Gets a list of ``Catalogs`` matching the given catalog query. arg: catalog_query (osid.cataloging.CatalogQuery): the catalog query return: (osid.cataloging.CatalogList) - the returned ``CatalogList`` raise: NullArgument - ``catalog_query`` is ``null`` ...
[ "Gets", "a", "list", "of", "Catalogs", "matching", "the", "given", "catalog", "query", "." ]
python
train
48.88
hydpy-dev/hydpy
hydpy/auxs/anntools.py
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/auxs/anntools.py#L1323-L1370
def refresh(self) -> None: """Prepare the actual |anntools.SeasonalANN| object for calculations. Dispite all automated refreshings explained in the general documentation on class |anntools.SeasonalANN|, it is still possible to destroy the inner consistency of a |anntools.SeasonalANN| in...
[ "def", "refresh", "(", "self", ")", "->", "None", ":", "# pylint: disable=unsupported-assignment-operation", "if", "self", ".", "_do_refresh", ":", "if", "self", ".", "anns", ":", "self", ".", "__sann", "=", "annutils", ".", "SeasonalANN", "(", "self", ".", ...
Prepare the actual |anntools.SeasonalANN| object for calculations. Dispite all automated refreshings explained in the general documentation on class |anntools.SeasonalANN|, it is still possible to destroy the inner consistency of a |anntools.SeasonalANN| instance, as it stores its |annt...
[ "Prepare", "the", "actual", "|anntools", ".", "SeasonalANN|", "object", "for", "calculations", "." ]
python
train
43.416667
bwhite/hadoopy
hadoopy/thirdparty/pyinstaller/PyInstaller/utils/winmanifest.py
https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/utils/winmanifest.py#L884-L887
def update_resources(self, dstpath, names=None, languages=None): """ Update or add manifest resource in dll/exe file dstpath """ UpdateManifestResourcesFromXML(dstpath, self.toprettyxml(), names, languages)
[ "def", "update_resources", "(", "self", ",", "dstpath", ",", "names", "=", "None", ",", "languages", "=", "None", ")", ":", "UpdateManifestResourcesFromXML", "(", "dstpath", ",", "self", ".", "toprettyxml", "(", ")", ",", "names", ",", "languages", ")" ]
Update or add manifest resource in dll/exe file dstpath
[ "Update", "or", "add", "manifest", "resource", "in", "dll", "/", "exe", "file", "dstpath" ]
python
train
64.75
SoCo/SoCo
soco/core.py
https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1950-L1977
def get_sonos_playlist_by_attr(self, attr_name, match): """Return the first Sonos Playlist DidlPlaylistContainer that matches the attribute specified. Args: attr_name (str): DidlPlaylistContainer attribute to compare. The most useful being: 'title' and 'item_id'. ...
[ "def", "get_sonos_playlist_by_attr", "(", "self", ",", "attr_name", ",", "match", ")", ":", "for", "sonos_playlist", "in", "self", ".", "get_sonos_playlists", "(", ")", ":", "if", "getattr", "(", "sonos_playlist", ",", "attr_name", ")", "==", "match", ":", "...
Return the first Sonos Playlist DidlPlaylistContainer that matches the attribute specified. Args: attr_name (str): DidlPlaylistContainer attribute to compare. The most useful being: 'title' and 'item_id'. match (str): Value to match. Returns: ...
[ "Return", "the", "first", "Sonos", "Playlist", "DidlPlaylistContainer", "that", "matches", "the", "attribute", "specified", "." ]
python
train
38.785714
apache/incubator-superset
superset/views/core.py
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L106-L123
def check_datasource_perms(self, datasource_type=None, datasource_id=None): """ Check if user can access a cached response from explore_json. This function takes `self` since it must have the same signature as the the decorated method. """ form_data = get_form_data()[0] datasource_id, data...
[ "def", "check_datasource_perms", "(", "self", ",", "datasource_type", "=", "None", ",", "datasource_id", "=", "None", ")", ":", "form_data", "=", "get_form_data", "(", ")", "[", "0", "]", "datasource_id", ",", "datasource_type", "=", "get_datasource_info", "(", ...
Check if user can access a cached response from explore_json. This function takes `self` since it must have the same signature as the the decorated method.
[ "Check", "if", "user", "can", "access", "a", "cached", "response", "from", "explore_json", "." ]
python
train
34.166667
spacetelescope/pysynphot
pysynphot/observation.py
https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/observation.py#L26-L78
def check_overlap(a, b): """Check for wavelength overlap between two spectra. .. note:: Generalized from :meth:`pysynphot.spectrum.SpectralElement.check_overlap`. Parameters ---------- a, b : `~pysynphot.spectrum.SourceSpectrum` or `~pysynphot.spectrum.SpectralElement` Typi...
[ "def", "check_overlap", "(", "a", ",", "b", ")", ":", "if", "a", ".", "isAnalytic", "or", "b", ".", "isAnalytic", ":", "#then it's defined everywhere", "result", "=", "'full'", "else", ":", "#get the wavelength arrays", "waves", "=", "list", "(", ")", "for",...
Check for wavelength overlap between two spectra. .. note:: Generalized from :meth:`pysynphot.spectrum.SpectralElement.check_overlap`. Parameters ---------- a, b : `~pysynphot.spectrum.SourceSpectrum` or `~pysynphot.spectrum.SpectralElement` Typically a source spectrum, spectra...
[ "Check", "for", "wavelength", "overlap", "between", "two", "spectra", "." ]
python
train
26.188679
aio-libs/yarl
yarl/__init__.py
https://github.com/aio-libs/yarl/blob/e47da02c00ad764e030ca7647a9565548c97d362/yarl/__init__.py#L790-L809
def with_port(self, port): """Return a new URL with port replaced. Clear port to default if None is passed. """ # N.B. doesn't cleanup query/fragment if port is not None and not isinstance(port, int): raise TypeError("port should be int or None, got {}".format(type(...
[ "def", "with_port", "(", "self", ",", "port", ")", ":", "# N.B. doesn't cleanup query/fragment", "if", "port", "is", "not", "None", "and", "not", "isinstance", "(", "port", ",", "int", ")", ":", "raise", "TypeError", "(", "\"port should be int or None, got {}\"", ...
Return a new URL with port replaced. Clear port to default if None is passed.
[ "Return", "a", "new", "URL", "with", "port", "replaced", "." ]
python
train
34.8
rameshg87/pyremotevbox
pyremotevbox/ZSI/schema.py
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/schema.py#L164-L189
def getElementDeclaration(cls, namespaceURI, name, isref=False, lazy=False): '''Grab an element declaration, returns a typecode instance representation or a typecode class definition. An element reference has its own facets, and is local so it will not be cached. Parameters: ...
[ "def", "getElementDeclaration", "(", "cls", ",", "namespaceURI", ",", "name", ",", "isref", "=", "False", ",", "lazy", "=", "False", ")", ":", "key", "=", "(", "namespaceURI", ",", "name", ")", "if", "isref", ":", "klass", "=", "cls", ".", "elements", ...
Grab an element declaration, returns a typecode instance representation or a typecode class definition. An element reference has its own facets, and is local so it will not be cached. Parameters: namespaceURI -- name -- isref -- if element referen...
[ "Grab", "an", "element", "declaration", "returns", "a", "typecode", "instance", "representation", "or", "a", "typecode", "class", "definition", ".", "An", "element", "reference", "has", "its", "own", "facets", "and", "is", "local", "so", "it", "will", "not", ...
python
train
36.615385
awentzonline/keras-vgg-buddy
keras_vgg_buddy/models.py
https://github.com/awentzonline/keras-vgg-buddy/blob/716cb66396b839a66ec8dc66998066b360a8f395/keras_vgg_buddy/models.py#L48-L53
def get_layer_output(self, name): '''Get symbolic output of a layer.''' if not name in self._f_layer_outputs: layer = self.net.get_layer(name) self._f_layer_outputs[name] = layer.output return self._f_layer_outputs[name]
[ "def", "get_layer_output", "(", "self", ",", "name", ")", ":", "if", "not", "name", "in", "self", ".", "_f_layer_outputs", ":", "layer", "=", "self", ".", "net", ".", "get_layer", "(", "name", ")", "self", ".", "_f_layer_outputs", "[", "name", "]", "="...
Get symbolic output of a layer.
[ "Get", "symbolic", "output", "of", "a", "layer", "." ]
python
test
43.833333
ministryofjustice/django-moj-irat
moj_irat/healthchecks.py
https://github.com/ministryofjustice/django-moj-irat/blob/c1588426fffce783bef6d8b9d73395a5e9a833c9/moj_irat/healthchecks.py#L196-L228
def run_healthchecks(self): """ Runs all registered healthchecks and returns a list of HealthcheckResponse. """ if not self._registry_loaded: self.load_healthchecks() def get_healthcheck_name(hc): if hasattr(hc, 'name'): return hc....
[ "def", "run_healthchecks", "(", "self", ")", ":", "if", "not", "self", ".", "_registry_loaded", ":", "self", ".", "load_healthchecks", "(", ")", "def", "get_healthcheck_name", "(", "hc", ")", ":", "if", "hasattr", "(", "hc", ",", "'name'", ")", ":", "ret...
Runs all registered healthchecks and returns a list of HealthcheckResponse.
[ "Runs", "all", "registered", "healthchecks", "and", "returns", "a", "list", "of", "HealthcheckResponse", "." ]
python
train
34.121212
QUANTAXIS/QUANTAXIS
QUANTAXIS/QAData/base_datastruct.py
https://github.com/QUANTAXIS/QUANTAXIS/blob/bb1fe424e4108b62a1f712b81a05cf829297a5c0/QUANTAXIS/QAData/base_datastruct.py#L513-L518
def mean_harmonic(self): '返回DataStruct.price的调和平均数' res = self.price.groupby(level=1 ).apply(lambda x: statistics.harmonic_mean(x)) res.name = 'mean_harmonic' return res
[ "def", "mean_harmonic", "(", "self", ")", ":", "res", "=", "self", ".", "price", ".", "groupby", "(", "level", "=", "1", ")", ".", "apply", "(", "lambda", "x", ":", "statistics", ".", "harmonic_mean", "(", "x", ")", ")", "res", ".", "name", "=", ...
返回DataStruct.price的调和平均数
[ "返回DataStruct", ".", "price的调和平均数" ]
python
train
38
foremast/foremast
src/foremast/awslambda/api_gateway_event/api_gateway_event.py
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/api_gateway_event/api_gateway_event.py#L167-L180
def create_api_key(self): """Create API Key for API access.""" apikeys = self.client.get_api_keys() for key in apikeys['items']: if key['name'] == self.app_name: self.log.info("Key %s already exists", self.app_name) break else: self...
[ "def", "create_api_key", "(", "self", ")", ":", "apikeys", "=", "self", ".", "client", ".", "get_api_keys", "(", ")", "for", "key", "in", "apikeys", "[", "'items'", "]", ":", "if", "key", "[", "'name'", "]", "==", "self", ".", "app_name", ":", "self"...
Create API Key for API access.
[ "Create", "API", "Key", "for", "API", "access", "." ]
python
train
43.857143
saltstack/salt
salt/modules/at.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/at.py#L63-L163
def atq(tag=None): ''' List all queued and running jobs or only those with an optional 'tag'. CLI Example: .. code-block:: bash salt '*' at.atq salt '*' at.atq [tag] salt '*' at.atq [job number] ''' jobs = [] # Shim to produce output similar to what __virtual_...
[ "def", "atq", "(", "tag", "=", "None", ")", ":", "jobs", "=", "[", "]", "# Shim to produce output similar to what __virtual__() should do", "# but __salt__ isn't available in __virtual__()", "# Tested on CentOS 5.8", "if", "__grains__", "[", "'os_family'", "]", "==", "'RedH...
List all queued and running jobs or only those with an optional 'tag'. CLI Example: .. code-block:: bash salt '*' at.atq salt '*' at.atq [tag] salt '*' at.atq [job number]
[ "List", "all", "queued", "and", "running", "jobs", "or", "only", "those", "with", "an", "optional", "tag", "." ]
python
train
32.445545
JukeboxPipeline/jukebox-core
src/jukeboxcore/gui/widgets/filebrowser.py
https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/widgets/filebrowser.py#L767-L787
def get_current_selection(self, i=None): """Get the :class:`TaskFileInfo` for the file selected in the active tab :param i: If None, returns selection of active tab. If 0, assetselection. If 1, shotselection :type i: :returns: The taskfile info in the currently active tab :rtype...
[ "def", "get_current_selection", "(", "self", ",", "i", "=", "None", ")", ":", "taskfile", "=", "None", "if", "(", "i", "is", "None", "and", "self", ".", "selection_tabw", ".", "currentIndex", "(", ")", "==", "0", ")", "or", "(", "i", "is", "not", "...
Get the :class:`TaskFileInfo` for the file selected in the active tab :param i: If None, returns selection of active tab. If 0, assetselection. If 1, shotselection :type i: :returns: The taskfile info in the currently active tab :rtype: :class:`TaskFileInfo` | None :raises: None
[ "Get", "the", ":", "class", ":", "TaskFileInfo", "for", "the", "file", "selected", "in", "the", "active", "tab" ]
python
train
48.904762
mikekatz04/BOWIE
bowie/plotutils/plottypes.py
https://github.com/mikekatz04/BOWIE/blob/a941342a3536cb57c817a1643896d99a3f354a86/bowie/plotutils/plottypes.py#L194-L223
def make_plot(self): """Make the horizon plot. """ self.get_contour_values() # sets levels of main contour plot colors1 = ['blue', 'green', 'red', 'purple', 'orange', 'gold', 'magenta'] # set contour value. Default is SNR_CUT. self.snr_contou...
[ "def", "make_plot", "(", "self", ")", ":", "self", ".", "get_contour_values", "(", ")", "# sets levels of main contour plot", "colors1", "=", "[", "'blue'", ",", "'green'", ",", "'red'", ",", "'purple'", ",", "'orange'", ",", "'gold'", ",", "'magenta'", "]", ...
Make the horizon plot.
[ "Make", "the", "horizon", "plot", "." ]
python
train
37.9
PmagPy/PmagPy
pmagpy/ipmag.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/ipmag.py#L2736-L2977
def ani_depthplot2(ani_file='rmag_anisotropy.txt', meas_file='magic_measurements.txt', samp_file='er_samples.txt', age_file=None, sum_file=None, fmt='svg', dmin=-1, dmax=-1, depth_scale='sample_core_depth', dir_path='.'): """ returns matplotlib figure with anisotropy data plotted against depth available dep...
[ "def", "ani_depthplot2", "(", "ani_file", "=", "'rmag_anisotropy.txt'", ",", "meas_file", "=", "'magic_measurements.txt'", ",", "samp_file", "=", "'er_samples.txt'", ",", "age_file", "=", "None", ",", "sum_file", "=", "None", ",", "fmt", "=", "'svg'", ",", "dmin...
returns matplotlib figure with anisotropy data plotted against depth available depth scales: 'sample_composite_depth', 'sample_core_depth', or 'age' (you must provide an age file to use this option)
[ "returns", "matplotlib", "figure", "with", "anisotropy", "data", "plotted", "against", "depth", "available", "depth", "scales", ":", "sample_composite_depth", "sample_core_depth", "or", "age", "(", "you", "must", "provide", "an", "age", "file", "to", "use", "this"...
python
train
41.657025
quantopian/alphalens
alphalens/performance.py
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L1021-L1088
def factor_cumulative_returns(factor_data, period, long_short=True, group_neutral=False, equal_weight=False, quantiles=None, groups=None): ...
[ "def", "factor_cumulative_returns", "(", "factor_data", ",", "period", ",", "long_short", "=", "True", ",", "group_neutral", "=", "False", ",", "equal_weight", "=", "False", ",", "quantiles", "=", "None", ",", "groups", "=", "None", ")", ":", "fwd_ret_cols", ...
Simulate a portfolio using the factor in input and returns the cumulative returns of the simulated portfolio Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex DataFrame indexed by date (level 0) and asset (level 1), containing the values for a single alpha facto...
[ "Simulate", "a", "portfolio", "using", "the", "factor", "in", "input", "and", "returns", "the", "cumulative", "returns", "of", "the", "simulated", "portfolio" ]
python
train
39.279412
jeremymcrae/denovonear
denovonear/ensembl_requester.py
https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/ensembl_requester.py#L308-L322
def get_chrom_for_transcript(self, transcript_id, hgnc_id): """ obtain the sequence for a transcript from ensembl """ headers = {"content-type": "application/json"} self.attempt = 0 ext = "/overlap/id/{}?feature=gene".format(transcript_id) r = self.ense...
[ "def", "get_chrom_for_transcript", "(", "self", ",", "transcript_id", ",", "hgnc_id", ")", ":", "headers", "=", "{", "\"content-type\"", ":", "\"application/json\"", "}", "self", ".", "attempt", "=", "0", "ext", "=", "\"/overlap/id/{}?feature=gene\"", ".", "format...
obtain the sequence for a transcript from ensembl
[ "obtain", "the", "sequence", "for", "a", "transcript", "from", "ensembl" ]
python
train
33.333333
costastf/toonlib
toonlib/toonlib.py
https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/toonlib/toonlib.py#L162-L188
def _state(self): """The internal state of the object. The api responses are not consistent so a retry is performed on every call with information updating the internally saved state refreshing the data. The info is cached for STATE_CACHING_SECONDS. :return: The current state o...
[ "def", "_state", "(", "self", ")", ":", "state", "=", "{", "}", "required_keys", "=", "(", "'deviceStatusInfo'", ",", "'gasUsage'", ",", "'powerUsage'", ",", "'thermostatInfo'", ",", "'thermostatStates'", ")", "try", ":", "for", "_", "in", "range", "(", "s...
The internal state of the object. The api responses are not consistent so a retry is performed on every call with information updating the internally saved state refreshing the data. The info is cached for STATE_CACHING_SECONDS. :return: The current state of the toons' information stat...
[ "The", "internal", "state", "of", "the", "object", "." ]
python
train
42.222222
softlayer/softlayer-python
SoftLayer/managers/network.py
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/network.py#L599-L634
def summary_by_datacenter(self): """Summary of the networks on the account, grouped by data center. The resultant dictionary is primarily useful for statistical purposes. It contains count information rather than raw data. If you want raw information, see the :func:`list_vlans` method i...
[ "def", "summary_by_datacenter", "(", "self", ")", ":", "datacenters", "=", "collections", ".", "defaultdict", "(", "lambda", ":", "{", "'hardware_count'", ":", "0", ",", "'public_ip_count'", ":", "0", ",", "'subnet_count'", ":", "0", ",", "'virtual_guest_count'"...
Summary of the networks on the account, grouped by data center. The resultant dictionary is primarily useful for statistical purposes. It contains count information rather than raw data. If you want raw information, see the :func:`list_vlans` method instead. :returns: A dictionary keye...
[ "Summary", "of", "the", "networks", "on", "the", "account", "grouped", "by", "data", "center", "." ]
python
train
40.611111
FNNDSC/pfmisc
pfmisc/C_snode.py
https://github.com/FNNDSC/pfmisc/blob/960b4d6135fcc50bed0a8e55db2ab1ddad9b99d8/pfmisc/C_snode.py#L589-L612
def pwd(self, **kwargs): """ Returns the cwd Optional kwargs: node = <node> If specified, return only the directory name at depth <node>. """ b_node = False node = 0 for key,val in kwargs.items():...
[ "def", "pwd", "(", "self", ",", "*", "*", "kwargs", ")", ":", "b_node", "=", "False", "node", "=", "0", "for", "key", ",", "val", "in", "kwargs", ".", "items", "(", ")", ":", "if", "key", "==", "'node'", ":", "b_node", "=", "True", "node", "=",...
Returns the cwd Optional kwargs: node = <node> If specified, return only the directory name at depth <node>.
[ "Returns", "the", "cwd" ]
python
train
26.791667
globus/globus-cli
globus_cli/commands/ls.py
https://github.com/globus/globus-cli/blob/336675ff24da64c5ee487243f39ae39fc49a7e14/globus_cli/commands/ls.py#L84-L150
def ls_command( endpoint_plus_path, recursive_depth_limit, recursive, long_output, show_hidden, filter_val, ): """ Executor for `globus ls` """ endpoint_id, path = endpoint_plus_path # do autoactivation before the `ls` call so that recursive invocations # won't do this r...
[ "def", "ls_command", "(", "endpoint_plus_path", ",", "recursive_depth_limit", ",", "recursive", ",", "long_output", ",", "show_hidden", ",", "filter_val", ",", ")", ":", "endpoint_id", ",", "path", "=", "endpoint_plus_path", "# do autoactivation before the `ls` call so th...
Executor for `globus ls`
[ "Executor", "for", "globus", "ls" ]
python
train
33.835821
laymonage/kbbi-python
kbbi/kbbi.py
https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L172-L184
def _nama(self): """Mengembalikan representasi string untuk nama entri ini. :returns: String representasi nama entri :rtype: str """ hasil = self.nama if self.nomor: hasil += " [{}]".format(self.nomor) if self.kata_dasar: hasil = " » ".jo...
[ "def", "_nama", "(", "self", ")", ":", "hasil", "=", "self", ".", "nama", "if", "self", ".", "nomor", ":", "hasil", "+=", "\" [{}]\"", ".", "format", "(", "self", ".", "nomor", ")", "if", "self", ".", "kata_dasar", ":", "hasil", "=", "\" » \".", "j...
Mengembalikan representasi string untuk nama entri ini. :returns: String representasi nama entri :rtype: str
[ "Mengembalikan", "representasi", "string", "untuk", "nama", "entri", "ini", "." ]
python
train
28
rvswift/EB
EB/builder/utilities/classification.py
https://github.com/rvswift/EB/blob/341880b79faf8147dc9fa6e90438531cd09fabcc/EB/builder/utilities/classification.py#L358-L380
def calculate_auc_covar(auc_structure1, auc_structure2): """ determine AUC covariance due to actives (covar_a) and decoys (covar_d) :param auc_structure1: list [(id, best_score, best_query, status, fpf, tpf), ...,] :param auc_structure2: list [(id, best_score, best_query, status, fpf, tpf), ...,] :r...
[ "def", "calculate_auc_covar", "(", "auc_structure1", ",", "auc_structure2", ")", ":", "# split data by activity class", "actives1", ",", "decoys1", "=", "splitter", "(", "auc_structure1", ")", "actives2", ",", "decoys2", "=", "splitter", "(", "auc_structure2", ")", ...
determine AUC covariance due to actives (covar_a) and decoys (covar_d) :param auc_structure1: list [(id, best_score, best_query, status, fpf, tpf), ...,] :param auc_structure2: list [(id, best_score, best_query, status, fpf, tpf), ...,] :return (covar_a, covar_d): tuple
[ "determine", "AUC", "covariance", "due", "to", "actives", "(", "covar_a", ")", "and", "decoys", "(", "covar_d", ")", ":", "param", "auc_structure1", ":", "list", "[", "(", "id", "best_score", "best_query", "status", "fpf", "tpf", ")", "...", "]", ":", "p...
python
train
39.826087
aws/aws-encryption-sdk-python
src/aws_encryption_sdk/streaming_client.py
https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/streaming_client.py#L859-L899
def _read_bytes_from_framed_body(self, b): """Reads the requested number of bytes from a streaming framed message body. :param int b: Number of bytes to read :returns: Bytes read from source stream and decrypted :rtype: bytes """ plaintext = b"" final_frame = Fal...
[ "def", "_read_bytes_from_framed_body", "(", "self", ",", "b", ")", ":", "plaintext", "=", "b\"\"", "final_frame", "=", "False", "_LOGGER", ".", "debug", "(", "\"collecting %d bytes\"", ",", "b", ")", "while", "len", "(", "plaintext", ")", "<", "b", "and", ...
Reads the requested number of bytes from a streaming framed message body. :param int b: Number of bytes to read :returns: Bytes read from source stream and decrypted :rtype: bytes
[ "Reads", "the", "requested", "number", "of", "bytes", "from", "a", "streaming", "framed", "message", "body", "." ]
python
train
45.926829
NarrativeScience/lsi
src/lsi/utils/hosts.py
https://github.com/NarrativeScience/lsi/blob/7d901b03fdb1a34ef795e5412bfe9685d948e32d/src/lsi/utils/hosts.py#L327-L344
def format_string(self, fmat_string): """ Takes a string containing 0 or more {variables} and formats it according to this instance's attributes. :param fmat_string: A string, e.g. '{name}-foo.txt' :type fmat_string: ``str`` :return: The string formatted according to th...
[ "def", "format_string", "(", "self", ",", "fmat_string", ")", ":", "try", ":", "return", "fmat_string", ".", "format", "(", "*", "*", "vars", "(", "self", ")", ")", "except", "KeyError", "as", "e", ":", "raise", "ValueError", "(", "'Invalid format string: ...
Takes a string containing 0 or more {variables} and formats it according to this instance's attributes. :param fmat_string: A string, e.g. '{name}-foo.txt' :type fmat_string: ``str`` :return: The string formatted according to this instance. E.g. 'production-runtime-foo...
[ "Takes", "a", "string", "containing", "0", "or", "more", "{", "variables", "}", "and", "formats", "it", "according", "to", "this", "instance", "s", "attributes", "." ]
python
test
39.333333
ungarj/mapchete
mapchete/formats/default/png.py
https://github.com/ungarj/mapchete/blob/d482918d0e66a5b414dff6aa7cc854e01fc60ee4/mapchete/formats/default/png.py#L181-L195
def for_web(self, data): """ Convert data to web output. Parameters ---------- data : array Returns ------- web data : array """ rgba = self._prepare_array_for_png(data) data = ma.masked_where(rgba == self.nodata, rgba) re...
[ "def", "for_web", "(", "self", ",", "data", ")", ":", "rgba", "=", "self", ".", "_prepare_array_for_png", "(", "data", ")", "data", "=", "ma", ".", "masked_where", "(", "rgba", "==", "self", ".", "nodata", ",", "rgba", ")", "return", "memory_file", "("...
Convert data to web output. Parameters ---------- data : array Returns ------- web data : array
[ "Convert", "data", "to", "web", "output", "." ]
python
valid
23.8
marrow/mongo
web/session/mongo.py
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/web/session/mongo.py#L92-L98
def persist(self, context): """Update or insert the session document into the configured collection""" D = self._Document document = context.session[self.name] D.get_collection().replace_one(D.id == document.id, document, True)
[ "def", "persist", "(", "self", ",", "context", ")", ":", "D", "=", "self", ".", "_Document", "document", "=", "context", ".", "session", "[", "self", ".", "name", "]", "D", ".", "get_collection", "(", ")", ".", "replace_one", "(", "D", ".", "id", "...
Update or insert the session document into the configured collection
[ "Update", "or", "insert", "the", "session", "document", "into", "the", "configured", "collection" ]
python
train
33.571429
chrisspen/burlap
burlap/deploy.py
https://github.com/chrisspen/burlap/blob/a92b0a8e5206850bb777c74af8421ea8b33779bd/burlap/deploy.py#L247-L275
def preview(self, components=None, ask=0): """ Inspects differences between the last deployment and the current code state. """ ask = int(ask) self.init() component_order, plan_funcs = self.get_component_funcs(components=components) print('\n%i changes found f...
[ "def", "preview", "(", "self", ",", "components", "=", "None", ",", "ask", "=", "0", ")", ":", "ask", "=", "int", "(", "ask", ")", "self", ".", "init", "(", ")", "component_order", ",", "plan_funcs", "=", "self", ".", "get_component_funcs", "(", "com...
Inspects differences between the last deployment and the current code state.
[ "Inspects", "differences", "between", "the", "last", "deployment", "and", "the", "current", "code", "state", "." ]
python
valid
37.206897
CalebBell/fluids
fluids/particle_size_distribution.py
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/particle_size_distribution.py#L1360-L1417
def dn(self, fraction, n=None): r'''Computes the diameter at which a specified `fraction` of the distribution falls under. Utilizes a bounded solver to search for the desired diameter. Parameters ---------- fraction : float Fraction of the distribution which...
[ "def", "dn", "(", "self", ",", "fraction", ",", "n", "=", "None", ")", ":", "if", "fraction", "==", "1.0", ":", "# Avoid returning the maximum value of the search interval", "fraction", "=", "1.0", "-", "epsilon", "if", "fraction", "<", "0", ":", "raise", "V...
r'''Computes the diameter at which a specified `fraction` of the distribution falls under. Utilizes a bounded solver to search for the desired diameter. Parameters ---------- fraction : float Fraction of the distribution which should be under the calculated ...
[ "r", "Computes", "the", "diameter", "at", "which", "a", "specified", "fraction", "of", "the", "distribution", "falls", "under", ".", "Utilizes", "a", "bounded", "solver", "to", "search", "for", "the", "desired", "diameter", "." ]
python
train
37.448276
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxfile.py
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxfile.py#L256-L271
def _new(self, dx_hash, media_type=None, **kwargs): """ :param dx_hash: Standard hash populated in :func:`dxpy.bindings.DXDataObject.new()` containing attributes common to all data object classes. :type dx_hash: dict :param media_type: Internet Media Type :type media_type: string...
[ "def", "_new", "(", "self", ",", "dx_hash", ",", "media_type", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "media_type", "is", "not", "None", ":", "dx_hash", "[", "\"media\"", "]", "=", "media_type", "resp", "=", "dxpy", ".", "api", ".", ...
:param dx_hash: Standard hash populated in :func:`dxpy.bindings.DXDataObject.new()` containing attributes common to all data object classes. :type dx_hash: dict :param media_type: Internet Media Type :type media_type: string Creates a new remote file with media type *media_type*, if giv...
[ ":", "param", "dx_hash", ":", "Standard", "hash", "populated", "in", ":", "func", ":", "dxpy", ".", "bindings", ".", "DXDataObject", ".", "new", "()", "containing", "attributes", "common", "to", "all", "data", "object", "classes", ".", ":", "type", "dx_has...
python
train
36.0625
peri-source/peri
peri/util.py
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L572-L585
def pad(self, pad): """ Pad this tile by an equal amount on each side as specified by pad >>> Tile(10).pad(2) Tile [-2, -2, -2] -> [12, 12, 12] ([14, 14, 14]) >>> Tile(10).pad([1,2,3]) Tile [-1, -2, -3] -> [11, 12, 13] ([12, 14, 16]) """ tile = self.copy...
[ "def", "pad", "(", "self", ",", "pad", ")", ":", "tile", "=", "self", ".", "copy", "(", ")", "tile", ".", "l", "-=", "pad", "tile", ".", "r", "+=", "pad", "return", "tile" ]
Pad this tile by an equal amount on each side as specified by pad >>> Tile(10).pad(2) Tile [-2, -2, -2] -> [12, 12, 12] ([14, 14, 14]) >>> Tile(10).pad([1,2,3]) Tile [-1, -2, -3] -> [11, 12, 13] ([12, 14, 16])
[ "Pad", "this", "tile", "by", "an", "equal", "amount", "on", "each", "side", "as", "specified", "by", "pad" ]
python
valid
26.642857
brocade/pynos
pynos/versions/ver_7/ver_7_1_0/yang/brocade_lldp_ext.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_lldp_ext.py#L212-L228
def get_lldp_neighbor_detail_output_lldp_neighbor_detail_remote_port_description(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_lldp_neighbor_detail = ET.Element("get_lldp_neighbor_detail") config = get_lldp_neighbor_detail output = ET.SubEl...
[ "def", "get_lldp_neighbor_detail_output_lldp_neighbor_detail_remote_port_description", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "get_lldp_neighbor_detail", "=", "ET", ".", "Element", "(", "\"get_lldp_...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
60.647059
postlund/pyatv
pyatv/mrp/srp.py
https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/srp.py#L129-L143
def verify2(self): """Last verification step. The derived keys (output, input) are returned here. """ output_key = hkdf_expand('MediaRemote-Salt', 'MediaRemote-Write-Encryption-Key', self._shared) input_key = hkd...
[ "def", "verify2", "(", "self", ")", ":", "output_key", "=", "hkdf_expand", "(", "'MediaRemote-Salt'", ",", "'MediaRemote-Write-Encryption-Key'", ",", "self", ".", "_shared", ")", "input_key", "=", "hkdf_expand", "(", "'MediaRemote-Salt'", ",", "'MediaRemote-Read-Encry...
Last verification step. The derived keys (output, input) are returned here.
[ "Last", "verification", "step", "." ]
python
train
37.133333
dead-beef/markovchain
markovchain/text/scanner.py
https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/text/scanner.py#L166-L177
def save(self): """Convert to JSON. Returns ------- `dict` JSON data. """ data = super().save() data['end_chars'] = self.end_chars data['default_end'] = self.default_end return data
[ "def", "save", "(", "self", ")", ":", "data", "=", "super", "(", ")", ".", "save", "(", ")", "data", "[", "'end_chars'", "]", "=", "self", ".", "end_chars", "data", "[", "'default_end'", "]", "=", "self", ".", "default_end", "return", "data" ]
Convert to JSON. Returns ------- `dict` JSON data.
[ "Convert", "to", "JSON", "." ]
python
train
21.25
ioam/parambokeh
parambokeh/widgets.py
https://github.com/ioam/parambokeh/blob/fb9744f216273c7b24e65d037b1d621c08d7fde6/parambokeh/widgets.py#L16-L20
def TextWidget(*args, **kw): """Forces a parameter value to be text""" kw['value'] = str(kw['value']) kw.pop('options', None) return TextInput(*args,**kw)
[ "def", "TextWidget", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "kw", "[", "'value'", "]", "=", "str", "(", "kw", "[", "'value'", "]", ")", "kw", ".", "pop", "(", "'options'", ",", "None", ")", "return", "TextInput", "(", "*", "args", ","...
Forces a parameter value to be text
[ "Forces", "a", "parameter", "value", "to", "be", "text" ]
python
test
33.2
tvgrabbers/DataTree
DataTreeGrab.py
https://github.com/tvgrabbers/DataTree/blob/f3ee73645147a5fd5158eb10877c7c3861a4d146/DataTreeGrab.py#L73-L130
def is_data_value(searchpath, searchtree, dtype = None, empty_is_false = False): """ Follow searchpath through the datatree in searchtree and report if there exists a value of type dtype searchpath is a list of keys/indices If dtype is None check for any value you can also supply a tuple to dty...
[ "def", "is_data_value", "(", "searchpath", ",", "searchtree", ",", "dtype", "=", "None", ",", "empty_is_false", "=", "False", ")", ":", "if", "isinstance", "(", "searchpath", ",", "(", "str", ",", "unicode", ",", "int", ")", ")", ":", "searchpath", "=", ...
Follow searchpath through the datatree in searchtree and report if there exists a value of type dtype searchpath is a list of keys/indices If dtype is None check for any value you can also supply a tuple to dtype
[ "Follow", "searchpath", "through", "the", "datatree", "in", "searchtree", "and", "report", "if", "there", "exists", "a", "value", "of", "type", "dtype", "searchpath", "is", "a", "list", "of", "keys", "/", "indices", "If", "dtype", "is", "None", "check", "f...
python
train
29.310345
marshmallow-code/marshmallow
src/marshmallow/schema.py
https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/schema.py#L896-L913
def __apply_nested_option(self, option_name, field_names, set_operation): """Apply nested options to nested fields""" # Split nested field names on the first dot. nested_fields = [name.split('.', 1) for name in field_names if '.' in name] # Partition the nested field names by parent fiel...
[ "def", "__apply_nested_option", "(", "self", ",", "option_name", ",", "field_names", ",", "set_operation", ")", ":", "# Split nested field names on the first dot.", "nested_fields", "=", "[", "name", ".", "split", "(", "'.'", ",", "1", ")", "for", "name", "in", ...
Apply nested options to nested fields
[ "Apply", "nested", "options", "to", "nested", "fields" ]
python
train
57.055556
rocky/python3-trepan
trepan/bwcli.py
https://github.com/rocky/python3-trepan/blob/14e91bc0acce090d67be145b1ac040cab92ac5f3/trepan/bwcli.py#L73-L90
def _postprocess_options(dbg, opts): ''' Handle options (`opts') that feed into the debugger (`dbg')''' # Set dbg.settings['printset'] print_events = [] if opts.fntrace: print_events = ['c_call', 'c_return', 'call', 'return'] # if opts.linetrace: print_events += ['line'] if len(print_events): ...
[ "def", "_postprocess_options", "(", "dbg", ",", "opts", ")", ":", "# Set dbg.settings['printset']", "print_events", "=", "[", "]", "if", "opts", ".", "fntrace", ":", "print_events", "=", "[", "'c_call'", ",", "'c_return'", ",", "'call'", ",", "'return'", "]", ...
Handle options (`opts') that feed into the debugger (`dbg')
[ "Handle", "options", "(", "opts", ")", "that", "feed", "into", "the", "debugger", "(", "dbg", ")" ]
python
test
32
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_0/build/build_client.py
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/build/build_client.py#L1645-L1664
def add_definition_tags(self, tags, project, definition_id): """AddDefinitionTags. [Preview API] Adds multiple tags to a definition. :param [str] tags: The tags to add. :param str project: Project ID or project name :param int definition_id: The ID of the definition. :rty...
[ "def", "add_definition_tags", "(", "self", ",", "tags", ",", "project", ",", "definition_id", ")", ":", "route_values", "=", "{", "}", "if", "project", "is", "not", "None", ":", "route_values", "[", "'project'", "]", "=", "self", ".", "_serialize", ".", ...
AddDefinitionTags. [Preview API] Adds multiple tags to a definition. :param [str] tags: The tags to add. :param str project: Project ID or project name :param int definition_id: The ID of the definition. :rtype: [str]
[ "AddDefinitionTags", ".", "[", "Preview", "API", "]", "Adds", "multiple", "tags", "to", "a", "definition", ".", ":", "param", "[", "str", "]", "tags", ":", "The", "tags", "to", "add", ".", ":", "param", "str", "project", ":", "Project", "ID", "or", "...
python
train
51.35
jreinhardt/handkerchief
handkerchief/handkerchief.py
https://github.com/jreinhardt/handkerchief/blob/450291314ccbbf557b41a30ce9c523587758fe76/handkerchief/handkerchief.py#L248-L286
def collect_reponames(): """ Try to figure out a list of repos to consider by default from the contents of the working directory. """ reponames = [] #try to figure out the repo from git repo in current directory try: with open(os.devnull) as devnull: remote_data = subprocess.check_output(["git","remote","-v...
[ "def", "collect_reponames", "(", ")", ":", "reponames", "=", "[", "]", "#try to figure out the repo from git repo in current directory", "try", ":", "with", "open", "(", "os", ".", "devnull", ")", "as", "devnull", ":", "remote_data", "=", "subprocess", ".", "check...
Try to figure out a list of repos to consider by default from the contents of the working directory.
[ "Try", "to", "figure", "out", "a", "list", "of", "repos", "to", "consider", "by", "default", "from", "the", "contents", "of", "the", "working", "directory", "." ]
python
train
28.666667
mongodb/mongo-python-driver
pymongo/database.py
https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/database.py#L1243-L1269
def remove_user(self, name, session=None): """**DEPRECATED**: Remove user `name` from this :class:`Database`. User `name` will no longer have permissions to access this :class:`Database`. .. note:: remove_user is deprecated and will be removed in PyMongo 4.0. Use the dropUser...
[ "def", "remove_user", "(", "self", ",", "name", ",", "session", "=", "None", ")", ":", "warnings", ".", "warn", "(", "\"remove_user is deprecated and will be removed in \"", "\"PyMongo 4.0. Use db.command with dropUser \"", "\"instead\"", ",", "DeprecationWarning", ",", "...
**DEPRECATED**: Remove user `name` from this :class:`Database`. User `name` will no longer have permissions to access this :class:`Database`. .. note:: remove_user is deprecated and will be removed in PyMongo 4.0. Use the dropUser command instead:: db.command("dropUser",...
[ "**", "DEPRECATED", "**", ":", "Remove", "user", "name", "from", "this", ":", "class", ":", "Database", "." ]
python
train
40.888889
michaelkuty/django-service-templates
django_service_templates/engine.py
https://github.com/michaelkuty/django-service-templates/blob/4f85bd812aeac8e01e1031f2118a68b344793118/django_service_templates/engine.py#L11-L25
def render(self, name=None, template=None, context={}): ''''Render Template meta from jinja2 templates. ''' if isinstance(template, Template): _template = template else: _template = Template.objects.get(name=name) # Maybe cache or save local ? r...
[ "def", "render", "(", "self", ",", "name", "=", "None", ",", "template", "=", "None", ",", "context", "=", "{", "}", ")", ":", "if", "isinstance", "(", "template", ",", "Template", ")", ":", "_template", "=", "template", "else", ":", "_template", "="...
Render Template meta from jinja2 templates.
[ "Render", "Template", "meta", "from", "jinja2", "templates", "." ]
python
train
27.266667
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavplayback.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/tools/mavplayback.py#L150-L155
def slew(self, value): '''move to a given position in the file''' if float(value) != self.filepos: pos = float(value) * self.filesize self.mlog.f.seek(int(pos)) self.find_message()
[ "def", "slew", "(", "self", ",", "value", ")", ":", "if", "float", "(", "value", ")", "!=", "self", ".", "filepos", ":", "pos", "=", "float", "(", "value", ")", "*", "self", ".", "filesize", "self", ".", "mlog", ".", "f", ".", "seek", "(", "int...
move to a given position in the file
[ "move", "to", "a", "given", "position", "in", "the", "file" ]
python
train
37.833333
tjcsl/cslbot
cslbot/helpers/handler.py
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/helpers/handler.py#L318-L343
def do_mode(self, target, msg, nick, send): """reop and handle guard violations.""" mode_changes = irc.modes.parse_channel_modes(msg) with self.data_lock: for change in mode_changes: if change[1] == 'v': self.voiced[target][change[2]] = True if cha...
[ "def", "do_mode", "(", "self", ",", "target", ",", "msg", ",", "nick", ",", "send", ")", ":", "mode_changes", "=", "irc", ".", "modes", ".", "parse_channel_modes", "(", "msg", ")", "with", "self", ".", "data_lock", ":", "for", "change", "in", "mode_cha...
reop and handle guard violations.
[ "reop", "and", "handle", "guard", "violations", "." ]
python
train
54.230769
brutasse/graphite-api
graphite_api/functions.py
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L4146-L4175
def randomWalkFunction(requestContext, name, step=60): """ Short Alias: randomWalk() Returns a random walk starting at 0. This is great for testing when there is no real data in whisper. Example:: &target=randomWalk("The.time.series") This would create a series named "The.time.series...
[ "def", "randomWalkFunction", "(", "requestContext", ",", "name", ",", "step", "=", "60", ")", ":", "delta", "=", "timedelta", "(", "seconds", "=", "step", ")", "when", "=", "requestContext", "[", "\"startTime\"", "]", "values", "=", "[", "]", "current", ...
Short Alias: randomWalk() Returns a random walk starting at 0. This is great for testing when there is no real data in whisper. Example:: &target=randomWalk("The.time.series") This would create a series named "The.time.series" that contains points where x(t) == x(t-1)+random()-0.5, and x...
[ "Short", "Alias", ":", "randomWalk", "()" ]
python
train
28.633333
wtolson/gnsq
gnsq/nsqd.py
https://github.com/wtolson/gnsq/blob/0fd02578b2c9c5fa30626d78579db2a46c10edac/gnsq/nsqd.py#L600-L603
def unpause_topic(self, topic): """Resume message flow to channels of an existing, paused, topic.""" nsq.assert_valid_topic_name(topic) return self._request('POST', '/topic/unpause', fields={'topic': topic})
[ "def", "unpause_topic", "(", "self", ",", "topic", ")", ":", "nsq", ".", "assert_valid_topic_name", "(", "topic", ")", "return", "self", ".", "_request", "(", "'POST'", ",", "'/topic/unpause'", ",", "fields", "=", "{", "'topic'", ":", "topic", "}", ")" ]
Resume message flow to channels of an existing, paused, topic.
[ "Resume", "message", "flow", "to", "channels", "of", "an", "existing", "paused", "topic", "." ]
python
train
57
iotile/coretools
transport_plugins/jlink/iotile_transport_jlink/jlink.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/jlink/iotile_transport_jlink/jlink.py#L351-L374
def send_script_async(self, conn_id, data, progress_callback, callback): """Asynchronously send a a script to this IOTile device Args: conn_id (int): A unique identifer that will refer to this connection data (string): the script to send to the device progress_callba...
[ "def", "send_script_async", "(", "self", ",", "conn_id", ",", "data", ",", "progress_callback", ",", "callback", ")", ":", "def", "_on_finished", "(", "_name", ",", "_retval", ",", "exception", ")", ":", "if", "exception", "is", "not", "None", ":", "callba...
Asynchronously send a a script to this IOTile device Args: conn_id (int): A unique identifer that will refer to this connection data (string): the script to send to the device progress_callback (callable): A function to be called with status on our progress, called as: ...
[ "Asynchronously", "send", "a", "a", "script", "to", "this", "IOTile", "device" ]
python
train
54.916667
roamanalytics/mittens
mittens/np_mittens.py
https://github.com/roamanalytics/mittens/blob/dbf0c3f8d18651475cf7e21ab1ceb824c5f89150/mittens/np_mittens.py#L136-L154
def _apply_updates(self, gradients): """Apply AdaGrad update to parameters. Parameters ---------- gradients Returns ------- """ if not hasattr(self, 'optimizers'): self.optimizers = \ {obj: AdaGradOptimizer(self.learning_rate...
[ "def", "_apply_updates", "(", "self", ",", "gradients", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'optimizers'", ")", ":", "self", ".", "optimizers", "=", "{", "obj", ":", "AdaGradOptimizer", "(", "self", ".", "learning_rate", ")", "for", "obj...
Apply AdaGrad update to parameters. Parameters ---------- gradients Returns -------
[ "Apply", "AdaGrad", "update", "to", "parameters", "." ]
python
train
32.473684
ejeschke/ginga
ginga/ImageView.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/ImageView.py#L386-L389
def configure(self, width, height): """See :meth:`set_window_size`.""" self._imgwin_set = True self.set_window_size(width, height)
[ "def", "configure", "(", "self", ",", "width", ",", "height", ")", ":", "self", ".", "_imgwin_set", "=", "True", "self", ".", "set_window_size", "(", "width", ",", "height", ")" ]
See :meth:`set_window_size`.
[ "See", ":", "meth", ":", "set_window_size", "." ]
python
train
37.75
hvac/hvac
hvac/api/secrets_engines/identity.py
https://github.com/hvac/hvac/blob/cce5b86889193f622c2a72a4a1b7e1c9c8aff1ce/hvac/api/secrets_engines/identity.py#L309-L338
def merge_entities(self, from_entity_ids, to_entity_id, force=False, mount_point=DEFAULT_MOUNT_POINT): """Merge many entities into one entity. Supported methods: POST: /{mount_point}/entity/merge. Produces: 204 (empty body) :param from_entity_ids: Entity IDs which needs to get merg...
[ "def", "merge_entities", "(", "self", ",", "from_entity_ids", ",", "to_entity_id", ",", "force", "=", "False", ",", "mount_point", "=", "DEFAULT_MOUNT_POINT", ")", ":", "params", "=", "{", "'from_entity_ids'", ":", "from_entity_ids", ",", "'to_entity_id'", ":", ...
Merge many entities into one entity. Supported methods: POST: /{mount_point}/entity/merge. Produces: 204 (empty body) :param from_entity_ids: Entity IDs which needs to get merged. :type from_entity_ids: array :param to_entity_id: Entity ID into which all the other entities ...
[ "Merge", "many", "entities", "into", "one", "entity", "." ]
python
train
46.766667
mongodb/mongo-python-driver
pymongo/bulk.py
https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/bulk.py#L322-L350
def execute_command(self, generator, write_concern, session): """Execute using write commands. """ # nModified is only reported for write commands, not legacy ops. full_result = { "writeErrors": [], "writeConcernErrors": [], "nInserted": 0, ...
[ "def", "execute_command", "(", "self", ",", "generator", ",", "write_concern", ",", "session", ")", ":", "# nModified is only reported for write commands, not legacy ops.", "full_result", "=", "{", "\"writeErrors\"", ":", "[", "]", ",", "\"writeConcernErrors\"", ":", "[...
Execute using write commands.
[ "Execute", "using", "write", "commands", "." ]
python
train
34.827586
manns/pyspread
pyspread/src/gui/_grid.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L607-L617
def OnCellFontSize(self, event): """Cell font size event handler""" with undo.group(_("Font size")): self.grid.actions.set_attr("pointsize", event.size) self.grid.ForceRefresh() self.grid.update_attribute_toolbar() event.Skip()
[ "def", "OnCellFontSize", "(", "self", ",", "event", ")", ":", "with", "undo", ".", "group", "(", "_", "(", "\"Font size\"", ")", ")", ":", "self", ".", "grid", ".", "actions", ".", "set_attr", "(", "\"pointsize\"", ",", "event", ".", "size", ")", "se...
Cell font size event handler
[ "Cell", "font", "size", "event", "handler" ]
python
train
24.818182
nicolargo/glances
glances/attribute.py
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/attribute.py#L133-L135
def history_json(self, nb=0): """Return the history in ISO JSON format""" return [(i[0].isoformat(), i[1]) for i in self._history[-nb:]]
[ "def", "history_json", "(", "self", ",", "nb", "=", "0", ")", ":", "return", "[", "(", "i", "[", "0", "]", ".", "isoformat", "(", ")", ",", "i", "[", "1", "]", ")", "for", "i", "in", "self", ".", "_history", "[", "-", "nb", ":", "]", "]" ]
Return the history in ISO JSON format
[ "Return", "the", "history", "in", "ISO", "JSON", "format" ]
python
train
50
starling-lab/rnlp
rnlp/parse.py
https://github.com/starling-lab/rnlp/blob/72054cc2c0cbaea1d281bf3d56b271d4da29fc4a/rnlp/parse.py#L38-L46
def _writeBlock(block, blockID): '''writes the block to a file with the id''' with open("blockIDs.txt", "a") as fp: fp.write("blockID: " + str(blockID) + "\n") sentences = "" for sentence in block: sentences += sentence+"," fp.write("block sentences: "+sentences[:-1]+...
[ "def", "_writeBlock", "(", "block", ",", "blockID", ")", ":", "with", "open", "(", "\"blockIDs.txt\"", ",", "\"a\"", ")", "as", "fp", ":", "fp", ".", "write", "(", "\"blockID: \"", "+", "str", "(", "blockID", ")", "+", "\"\\n\"", ")", "sentences", "=",...
writes the block to a file with the id
[ "writes", "the", "block", "to", "a", "file", "with", "the", "id" ]
python
train
37.777778
reingart/gui2py
gui/component.py
https://github.com/reingart/gui2py/blob/aca0a05f6fcde55c94ad7cc058671a06608b01a4/gui/component.py#L741-L761
def _calc_dimension(self, dim_val, dim_max, font_dim): "Calculate final pos and size (auto, absolute in pixels & relativa)" if dim_val is None: return -1 # let wx automatic pos/size elif isinstance(dim_val, int): return dim_val # use fixed pixel value (absolute) ...
[ "def", "_calc_dimension", "(", "self", ",", "dim_val", ",", "dim_max", ",", "font_dim", ")", ":", "if", "dim_val", "is", "None", ":", "return", "-", "1", "# let wx automatic pos/size\r", "elif", "isinstance", "(", "dim_val", ",", "int", ")", ":", "return", ...
Calculate final pos and size (auto, absolute in pixels & relativa)
[ "Calculate", "final", "pos", "and", "size", "(", "auto", "absolute", "in", "pixels", "&", "relativa", ")" ]
python
test
46.142857
veltzer/pypitools
pypitools/common.py
https://github.com/veltzer/pypitools/blob/5f097be21e9bc65578eed5b6b7855c1945540701/pypitools/common.py#L207-L217
def upload(self): """ upload via the method configured :return: """ if self.upload_method == "setup": self.upload_by_setup() if self.upload_method == "twine": self.upload_by_twine() if self.upload_method == "gemfury": self.uploa...
[ "def", "upload", "(", "self", ")", ":", "if", "self", ".", "upload_method", "==", "\"setup\"", ":", "self", ".", "upload_by_setup", "(", ")", "if", "self", ".", "upload_method", "==", "\"twine\"", ":", "self", ".", "upload_by_twine", "(", ")", "if", "sel...
upload via the method configured :return:
[ "upload", "via", "the", "method", "configured", ":", "return", ":" ]
python
train
29.454545
pypa/pipenv
pipenv/vendor/distlib/_backport/shutil.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/shutil.py#L300-L338
def move(src, dst): """Recursively move a file or directory to another location. This is similar to the Unix "mv" command. If the destination is a directory or a symlink to a directory, the source is moved inside the directory. The destination path must not already exist. If the destination al...
[ "def", "move", "(", "src", ",", "dst", ")", ":", "real_dst", "=", "dst", "if", "os", ".", "path", ".", "isdir", "(", "dst", ")", ":", "if", "_samefile", "(", "src", ",", "dst", ")", ":", "# We might be on a case insensitive filesystem,", "# perform the ren...
Recursively move a file or directory to another location. This is similar to the Unix "mv" command. If the destination is a directory or a symlink to a directory, the source is moved inside the directory. The destination path must not already exist. If the destination already exists but is not a d...
[ "Recursively", "move", "a", "file", "or", "directory", "to", "another", "location", ".", "This", "is", "similar", "to", "the", "Unix", "mv", "command", "." ]
python
train
36.333333
ArchiveTeam/wpull
wpull/warc/recorder.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/warc/recorder.py#L410-L433
def _write_cdx_header(self): '''Write the CDX header. It writes the fields: 1. a: original URL 2. b: UNIX timestamp 3. m: MIME Type from the HTTP Content-type 4. s: response code 5. k: new style checksum 6. S: raw file record size 7. V: offset in...
[ "def", "_write_cdx_header", "(", "self", ")", ":", "with", "open", "(", "self", ".", "_cdx_filename", ",", "mode", "=", "'a'", ",", "encoding", "=", "'utf-8'", ")", "as", "out_file", ":", "out_file", ".", "write", "(", "self", ".", "CDX_DELIMINATOR", ")"...
Write the CDX header. It writes the fields: 1. a: original URL 2. b: UNIX timestamp 3. m: MIME Type from the HTTP Content-type 4. s: response code 5. k: new style checksum 6. S: raw file record size 7. V: offset in raw file 8. g: filename of raw ...
[ "Write", "the", "CDX", "header", "." ]
python
train
30.166667
robmarkcole/HASS-data-detective
detective/config.py
https://github.com/robmarkcole/HASS-data-detective/blob/f67dfde9dd63a3af411944d1857b0835632617c5/detective/config.py#L36-L49
def _secret_yaml(loader, node): """Load secrets and embed it into the configuration YAML.""" fname = os.path.join(os.path.dirname(loader.name), "secrets.yaml") try: with open(fname, encoding="utf-8") as secret_file: secrets = YAML(typ="safe").load(secret_file) except FileNotFoundErr...
[ "def", "_secret_yaml", "(", "loader", ",", "node", ")", ":", "fname", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "loader", ".", "name", ")", ",", "\"secrets.yaml\"", ")", "try", ":", "with", "open", "(", "fnam...
Load secrets and embed it into the configuration YAML.
[ "Load", "secrets", "and", "embed", "it", "into", "the", "configuration", "YAML", "." ]
python
train
37.928571
digmore/pypushed
pushed/pushed.py
https://github.com/digmore/pypushed/blob/4240fc27323b89d59f0c652dcea4b65f78437c5b/pushed/pushed.py#L37-L50
def push_channel(self, content, channel, content_url=None): '''Push a notification to a Pushed channel. Param: content -> content of Pushed notification message channel -> string identifying a Pushed channel content_url (optional) -> enrich message with URL Returns...
[ "def", "push_channel", "(", "self", ",", "content", ",", "channel", ",", "content_url", "=", "None", ")", ":", "parameters", "=", "{", "'app_key'", ":", "self", ".", "app_key", ",", "'app_secret'", ":", "self", ".", "app_secret", ",", "'target_alias'", ":"...
Push a notification to a Pushed channel. Param: content -> content of Pushed notification message channel -> string identifying a Pushed channel content_url (optional) -> enrich message with URL Returns Shipment ID as string
[ "Push", "a", "notification", "to", "a", "Pushed", "channel", "." ]
python
train
40.071429
hozn/coilmq
coilmq/store/sa/__init__.py
https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/store/sa/__init__.py#L151-L167
def has_frames(self, destination): """ Whether specified queue has any frames. @param destination: The queue name (destinationination). @type destination: C{str} @return: Whether there are any frames in the specified queue. @rtype: C{bool} """ session = ...
[ "def", "has_frames", "(", "self", ",", "destination", ")", ":", "session", "=", "meta", ".", "Session", "(", ")", "sel", "=", "select", "(", "[", "model", ".", "frames_table", ".", "c", ".", "message_id", "]", ")", ".", "where", "(", "model", ".", ...
Whether specified queue has any frames. @param destination: The queue name (destinationination). @type destination: C{str} @return: Whether there are any frames in the specified queue. @rtype: C{bool}
[ "Whether", "specified", "queue", "has", "any", "frames", "." ]
python
train
32.235294
Nekroze/librarian
librarian/deck.py
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/deck.py#L56-L62
def move_top_cards(self, other, number=1): """ Move the top `number` of cards to the top of some `other` deck. By default only one card will be moved if `number` is not specified. """ other.cards.append(reversed(self.cards[-number:]))
[ "def", "move_top_cards", "(", "self", ",", "other", ",", "number", "=", "1", ")", ":", "other", ".", "cards", ".", "append", "(", "reversed", "(", "self", ".", "cards", "[", "-", "number", ":", "]", ")", ")" ]
Move the top `number` of cards to the top of some `other` deck. By default only one card will be moved if `number` is not specified.
[ "Move", "the", "top", "number", "of", "cards", "to", "the", "top", "of", "some", "other", "deck", "." ]
python
train
38.428571
ejeschke/ginga
ginga/ImageView.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/ImageView.py#L3447-L3495
def set_onscreen_message(self, text, redraw=True): """Called by a subclass to update the onscreen message. Parameters ---------- text : str The text to show in the display. """ width, height = self.get_window_size() font = self.t_.get('onscreen_font...
[ "def", "set_onscreen_message", "(", "self", ",", "text", ",", "redraw", "=", "True", ")", ":", "width", ",", "height", "=", "self", ".", "get_window_size", "(", ")", "font", "=", "self", ".", "t_", ".", "get", "(", "'onscreen_font'", ",", "'sans serif'",...
Called by a subclass to update the onscreen message. Parameters ---------- text : str The text to show in the display.
[ "Called", "by", "a", "subclass", "to", "update", "the", "onscreen", "message", "." ]
python
train
30.918367
adamhadani/python-yelp
yelp/api.py
https://github.com/adamhadani/python-yelp/blob/7694ccb7274cc3c5783250ed0c3396cda2fcfa1a/yelp/api.py#L233-L243
def by_geopoint(self, lat, long): """ Perform a Yelp Neighborhood API Search based on a geopoint. Args: lat - geopoint latitude long - geopoint longitude """ header, content = self._http_request(self.BASE_URL, lat=lat, long=long) return...
[ "def", "by_geopoint", "(", "self", ",", "lat", ",", "long", ")", ":", "header", ",", "content", "=", "self", ".", "_http_request", "(", "self", ".", "BASE_URL", ",", "lat", "=", "lat", ",", "long", "=", "long", ")", "return", "json", ".", "loads", ...
Perform a Yelp Neighborhood API Search based on a geopoint. Args: lat - geopoint latitude long - geopoint longitude
[ "Perform", "a", "Yelp", "Neighborhood", "API", "Search", "based", "on", "a", "geopoint", "." ]
python
train
30
python-bugzilla/python-bugzilla
bugzilla/base.py
https://github.com/python-bugzilla/python-bugzilla/blob/7de8b225104f24a1eee3e837bf1e02d60aefe69f/bugzilla/base.py#L581-L621
def login(self, user=None, password=None, restrict_login=None): """ Attempt to log in using the given username and password. Subsequent method calls will use this username and password. Returns False if login fails, otherwise returns some kind of login info - typically either a n...
[ "def", "login", "(", "self", ",", "user", "=", "None", ",", "password", "=", "None", ",", "restrict_login", "=", "None", ")", ":", "if", "self", ".", "api_key", ":", "raise", "ValueError", "(", "\"cannot login when using an API key\"", ")", "if", "user", "...
Attempt to log in using the given username and password. Subsequent method calls will use this username and password. Returns False if login fails, otherwise returns some kind of login info - typically either a numeric userid, or a dict of user info. If user is not set, the value of Bug...
[ "Attempt", "to", "log", "in", "using", "the", "given", "username", "and", "password", ".", "Subsequent", "method", "calls", "will", "use", "this", "username", "and", "password", ".", "Returns", "False", "if", "login", "fails", "otherwise", "returns", "some", ...
python
train
38.268293
dasevilla/rovi-python
roviclient/base.py
https://github.com/dasevilla/rovi-python/blob/46039d6ebfcf2ff20b4edb4636cb972682cf6af4/roviclient/base.py#L52-L66
def make_request(self, resource, params=None): """ Performs the API request. Most methods are a wrapper around this one. """ if params is None: params = {} url = self.request_url(resource) params['format'] = 'json' r = self.session.get(url=url, param...
[ "def", "make_request", "(", "self", ",", "resource", ",", "params", "=", "None", ")", ":", "if", "params", "is", "None", ":", "params", "=", "{", "}", "url", "=", "self", ".", "request_url", "(", "resource", ")", "params", "[", "'format'", "]", "=", ...
Performs the API request. Most methods are a wrapper around this one.
[ "Performs", "the", "API", "request", ".", "Most", "methods", "are", "a", "wrapper", "around", "this", "one", "." ]
python
train
24.2
Cairnarvon/uptime
src/__init__.py
https://github.com/Cairnarvon/uptime/blob/1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb/src/__init__.py#L351-L365
def boottime(): """Returns boot time if remotely possible, or None if not.""" global __boottime if __boottime is None: up = uptime() if up is None: return None if __boottime is None: _boottime_linux() if datetime is None: raise RuntimeError('datetime mod...
[ "def", "boottime", "(", ")", ":", "global", "__boottime", "if", "__boottime", "is", "None", ":", "up", "=", "uptime", "(", ")", "if", "up", "is", "None", ":", "return", "None", "if", "__boottime", "is", "None", ":", "_boottime_linux", "(", ")", "if", ...
Returns boot time if remotely possible, or None if not.
[ "Returns", "boot", "time", "if", "remotely", "possible", "or", "None", "if", "not", "." ]
python
valid
25.866667
dswah/pyGAM
pygam/core.py
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/core.py#L156-L179
def set_params(self, deep=False, force=False, **parameters): """ sets an object's paramters Parameters ---------- deep : boolean, default: False when True, also sets non-user-facing paramters force : boolean, default: False when True, also sets pa...
[ "def", "set_params", "(", "self", ",", "deep", "=", "False", ",", "force", "=", "False", ",", "*", "*", "parameters", ")", ":", "param_names", "=", "self", ".", "get_params", "(", "deep", "=", "deep", ")", ".", "keys", "(", ")", "for", "parameter", ...
sets an object's paramters Parameters ---------- deep : boolean, default: False when True, also sets non-user-facing paramters force : boolean, default: False when True, also sets parameters that the object does not already have **parameters :...
[ "sets", "an", "object", "s", "paramters" ]
python
train
32.5
tweepy/tweepy
tweepy/streaming.py
https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/streaming.py#L167-L182
def read_line(self, sep=six.b('\n')): """Read the data stream until a given separator is found (default \n) :param sep: Separator to read until. Must by of the bytes type (str in python 2, bytes in python 3) :return: The str of the data read until sep """ start = 0 ...
[ "def", "read_line", "(", "self", ",", "sep", "=", "six", ".", "b", "(", "'\\n'", ")", ")", ":", "start", "=", "0", "while", "not", "self", ".", "_stream", ".", "closed", ":", "loc", "=", "self", ".", "_buffer", ".", "find", "(", "sep", ",", "st...
Read the data stream until a given separator is found (default \n) :param sep: Separator to read until. Must by of the bytes type (str in python 2, bytes in python 3) :return: The str of the data read until sep
[ "Read", "the", "data", "stream", "until", "a", "given", "separator", "is", "found", "(", "default", "\\", "n", ")" ]
python
train
38.3125
MacHu-GWU/uszipcode-project
uszipcode/search.py
https://github.com/MacHu-GWU/uszipcode-project/blob/96282b779a3efb422802de83c48ca284598ba952/uszipcode/search.py#L804-L819
def by_median_household_income(self, lower=-1, upper=2 ** 31, zipcode_type=ZipcodeType.Standard, sort_by=SimpleZipcode.median_household_income.name, ...
[ "def", "by_median_household_income", "(", "self", ",", "lower", "=", "-", "1", ",", "upper", "=", "2", "**", "31", ",", "zipcode_type", "=", "ZipcodeType", ".", "Standard", ",", "sort_by", "=", "SimpleZipcode", ".", "median_household_income", ".", "name", ",...
Search zipcode information by median household income.
[ "Search", "zipcode", "information", "by", "median", "household", "income", "." ]
python
train
44.5
PmagPy/PmagPy
dialogs/drop_down_menus3.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/dialogs/drop_down_menus3.py#L284-L397
def on_left_click(self, event, grid, choices): """ creates popup menu when user clicks on the column if that column is in the list of choices that get a drop-down menu. allows user to edit the column, but only from available values """ row, col = event.GetRow(), event.Get...
[ "def", "on_left_click", "(", "self", ",", "event", ",", "grid", ",", "choices", ")", ":", "row", ",", "col", "=", "event", ".", "GetRow", "(", ")", ",", "event", ".", "GetCol", "(", ")", "if", "col", "==", "0", "and", "self", ".", "grid", ".", ...
creates popup menu when user clicks on the column if that column is in the list of choices that get a drop-down menu. allows user to edit the column, but only from available values
[ "creates", "popup", "menu", "when", "user", "clicks", "on", "the", "column", "if", "that", "column", "is", "in", "the", "list", "of", "choices", "that", "get", "a", "drop", "-", "down", "menu", ".", "allows", "user", "to", "edit", "the", "column", "but...
python
train
46.280702
20c/tmpl
tmpl/__init__.py
https://github.com/20c/tmpl/blob/ed24d3b744353c93735f370a2b989ed322960ed9/tmpl/__init__.py#L10-L19
def get_engine(name): """ get an engine from string (engine class without Engine) """ name = name.capitalize() + 'Engine' if name in globals(): return globals()[name] raise KeyError("engine '%s' does not exist" % name)
[ "def", "get_engine", "(", "name", ")", ":", "name", "=", "name", ".", "capitalize", "(", ")", "+", "'Engine'", "if", "name", "in", "globals", "(", ")", ":", "return", "globals", "(", ")", "[", "name", "]", "raise", "KeyError", "(", "\"engine '%s' does ...
get an engine from string (engine class without Engine)
[ "get", "an", "engine", "from", "string", "(", "engine", "class", "without", "Engine", ")" ]
python
train
24.3
objectrocket/python-client
objectrocket/util.py
https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/util.py#L23-L31
def register_extension_method(ext, base, *args, **kwargs): """Register the given extension method as a public attribute of the given base. README: The expected protocol here is that the given extension method is an unbound function. It will be bound to the specified base as a method, and then set as a publ...
[ "def", "register_extension_method", "(", "ext", ",", "base", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "bound_method", "=", "create_bound_method", "(", "ext", ".", "plugin", ",", "base", ")", "setattr", "(", "base", ",", "ext", ".", "name", ...
Register the given extension method as a public attribute of the given base. README: The expected protocol here is that the given extension method is an unbound function. It will be bound to the specified base as a method, and then set as a public attribute of that base.
[ "Register", "the", "given", "extension", "method", "as", "a", "public", "attribute", "of", "the", "given", "base", "." ]
python
train
51.222222
bram85/topydo
topydo/ui/columns/Main.py
https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/ui/columns/Main.py#L479-L493
def _viewdata_to_view(self, p_data): """ Converts a dictionary describing a view to an actual UIView instance. """ sorter = Sorter(p_data['sortexpr'], p_data['groupexpr']) filters = [] if not p_data['show_all']: filters.append(DependencyFilter(self.todolist))...
[ "def", "_viewdata_to_view", "(", "self", ",", "p_data", ")", ":", "sorter", "=", "Sorter", "(", "p_data", "[", "'sortexpr'", "]", ",", "p_data", "[", "'groupexpr'", "]", ")", "filters", "=", "[", "]", "if", "not", "p_data", "[", "'show_all'", "]", ":",...
Converts a dictionary describing a view to an actual UIView instance.
[ "Converts", "a", "dictionary", "describing", "a", "view", "to", "an", "actual", "UIView", "instance", "." ]
python
train
35.133333
pywbem/pywbem
pywbem/cim_obj.py
https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/cim_obj.py#L1302-L1310
def namespace(self, namespace): """Setter method; for a description see the getter method.""" # pylint: disable=attribute-defined-outside-init self._namespace = _ensure_unicode(namespace) if self._namespace is not None: # In Python 3, a byte string cannot be stripped by a uni...
[ "def", "namespace", "(", "self", ",", "namespace", ")", ":", "# pylint: disable=attribute-defined-outside-init", "self", ".", "_namespace", "=", "_ensure_unicode", "(", "namespace", ")", "if", "self", ".", "_namespace", "is", "not", "None", ":", "# In Python 3, a by...
Setter method; for a description see the getter method.
[ "Setter", "method", ";", "for", "a", "description", "see", "the", "getter", "method", "." ]
python
train
53.111111
fridiculous/django-estimators
estimators/models/base.py
https://github.com/fridiculous/django-estimators/blob/5dd72694dab6725335214543a59104c4de504037/estimators/models/base.py#L30-L41
def _extract_model_params(self, defaults, **kwargs): """this method allows django managers use `objects.get_or_create` and `objects.update_or_create` on a hashable object. """ obj = kwargs.pop(self.object_property_name, None) if obj is not None: kwargs['object_hash'] ...
[ "def", "_extract_model_params", "(", "self", ",", "defaults", ",", "*", "*", "kwargs", ")", ":", "obj", "=", "kwargs", ".", "pop", "(", "self", ".", "object_property_name", ",", "None", ")", "if", "obj", "is", "not", "None", ":", "kwargs", "[", "'objec...
this method allows django managers use `objects.get_or_create` and `objects.update_or_create` on a hashable object.
[ "this", "method", "allows", "django", "managers", "use", "objects", ".", "get_or_create", "and", "objects", ".", "update_or_create", "on", "a", "hashable", "object", "." ]
python
train
46.916667
Rapptz/discord.py
discord/ext/commands/help.py
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L103-L133
def add_line(self, line='', *, empty=False): """Adds a line to the current page. If the line exceeds the :attr:`max_size` then an exception is raised. Parameters ----------- line: :class:`str` The line to add. empty: :class:`bool` Indicat...
[ "def", "add_line", "(", "self", ",", "line", "=", "''", ",", "*", ",", "empty", "=", "False", ")", ":", "max_page_size", "=", "self", ".", "max_size", "-", "self", ".", "_prefix_len", "-", "2", "if", "len", "(", "line", ")", ">", "max_page_size", "...
Adds a line to the current page. If the line exceeds the :attr:`max_size` then an exception is raised. Parameters ----------- line: :class:`str` The line to add. empty: :class:`bool` Indicates if another empty line should be added. Raise...
[ "Adds", "a", "line", "to", "the", "current", "page", "." ]
python
train
29.096774
offu/WeRoBot
werobot/pay.py
https://github.com/offu/WeRoBot/blob/fd42109105b03f9acf45ebd9dcabb9d5cff98f3c/werobot/pay.py#L60-L86
def create_js_pay_params(self, **package): """ 签名 js 需要的参数 详情请参考 支付开发文档 :: wxclient.create_js_pay_params( body=标题, out_trade_no=本地订单号, total_fee=价格单位分, notify_url=通知url, spbill_create_ip=建议为支付人ip, ) :param...
[ "def", "create_js_pay_params", "(", "self", ",", "*", "*", "package", ")", ":", "pay_param", ",", "sign", ",", "sign_type", "=", "self", ".", "_pay_sign_dict", "(", "package", "=", "self", ".", "create_js_pay_package", "(", "*", "*", "package", ")", ")", ...
签名 js 需要的参数 详情请参考 支付开发文档 :: wxclient.create_js_pay_params( body=标题, out_trade_no=本地订单号, total_fee=价格单位分, notify_url=通知url, spbill_create_ip=建议为支付人ip, ) :param package: 需要签名的的参数 :return: 支付需要的对象
[ "签名", "js", "需要的参数", "详情请参考", "支付开发文档" ]
python
train
26.777778
Duke-GCB/DukeDSClient
ddsc/core/download.py
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L464-L472
def _on_bytes_read(self, num_bytes_read): """ Record our progress so we can validate that we receive all the data :param num_bytes_read: int: number of bytes we received as part of one chunk """ self.actual_bytes_read += num_bytes_read if self.actual_bytes_read > self.byt...
[ "def", "_on_bytes_read", "(", "self", ",", "num_bytes_read", ")", ":", "self", ".", "actual_bytes_read", "+=", "num_bytes_read", "if", "self", ".", "actual_bytes_read", ">", "self", ".", "bytes_to_read", ":", "raise", "TooLargeChunkDownloadError", "(", "self", "."...
Record our progress so we can validate that we receive all the data :param num_bytes_read: int: number of bytes we received as part of one chunk
[ "Record", "our", "progress", "so", "we", "can", "validate", "that", "we", "receive", "all", "the", "data", ":", "param", "num_bytes_read", ":", "int", ":", "number", "of", "bytes", "we", "received", "as", "part", "of", "one", "chunk" ]
python
train
55.333333
h2oai/h2o-3
h2o-py/h2o/utils/debugging.py
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/utils/debugging.py#L238-L265
def _get_method_full_name(func): """ Return fully qualified function name. This method will attempt to find "full name" of the given function object. This full name is either of the form "<class name>.<method name>" if the function is a class method, or "<module name>.<func name>" if it's a regular...
[ "def", "_get_method_full_name", "(", "func", ")", ":", "# Python 3.3 already has this information available...", "if", "hasattr", "(", "func", ",", "\"__qualname__\"", ")", ":", "return", "func", ".", "__qualname__", "module", "=", "inspect", ".", "getmodule", "(", ...
Return fully qualified function name. This method will attempt to find "full name" of the given function object. This full name is either of the form "<class name>.<method name>" if the function is a class method, or "<module name>.<func name>" if it's a regular function. Thus, this is an attempt to back-p...
[ "Return", "fully", "qualified", "function", "name", "." ]
python
test
40.75
benvanwerkhoven/kernel_tuner
kernel_tuner/util.py
https://github.com/benvanwerkhoven/kernel_tuner/blob/cfcb5da5e510db494f8219c22566ab65d5fcbd9f/kernel_tuner/util.py#L34-L68
def check_argument_list(kernel_name, kernel_string, args): """ raise an exception if a kernel arguments do not match host arguments """ kernel_arguments = list() collected_errors = list() for iterator in re.finditer(kernel_name + "[ \n\t]*" + "\(", kernel_string): kernel_start = iterator.end() ...
[ "def", "check_argument_list", "(", "kernel_name", ",", "kernel_string", ",", "args", ")", ":", "kernel_arguments", "=", "list", "(", ")", "collected_errors", "=", "list", "(", ")", "for", "iterator", "in", "re", ".", "finditer", "(", "kernel_name", "+", "\"[...
raise an exception if a kernel arguments do not match host arguments
[ "raise", "an", "exception", "if", "a", "kernel", "arguments", "do", "not", "match", "host", "arguments" ]
python
train
52.485714
prompt-toolkit/ptpython
ptpython/contrib/asyncssh_repl.py
https://github.com/prompt-toolkit/ptpython/blob/b1bba26a491324cd65e0ef46c7b818c4b88fd993/ptpython/contrib/asyncssh_repl.py#L118-L133
def _print(self, *data, **kw): """ _print(self, *data, sep=' ', end='\n', file=None) Alternative 'print' function that prints back into the SSH channel. """ # Pop keyword-only arguments. (We cannot use the syntax from the # signature. Otherwise, Python2 will give a synta...
[ "def", "_print", "(", "self", ",", "*", "data", ",", "*", "*", "kw", ")", ":", "# Pop keyword-only arguments. (We cannot use the syntax from the", "# signature. Otherwise, Python2 will give a syntax error message when", "# installing.)", "sep", "=", "kw", ".", "pop", "(", ...
_print(self, *data, sep=' ', end='\n', file=None) Alternative 'print' function that prints back into the SSH channel.
[ "_print", "(", "self", "*", "data", "sep", "=", "end", "=", "\\", "n", "file", "=", "None", ")" ]
python
train
36.4375
philgyford/django-spectator
spectator/events/views.py
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/events/views.py#L147-L153
def get_work_kind(self): """ We'll have a kind_slug like 'movies'. We need to translate that into a work `kind` like 'movie'. """ slugs_to_kinds = {v:k for k,v in Work.KIND_SLUGS.items()} return slugs_to_kinds.get(self.kind_slug, None)
[ "def", "get_work_kind", "(", "self", ")", ":", "slugs_to_kinds", "=", "{", "v", ":", "k", "for", "k", ",", "v", "in", "Work", ".", "KIND_SLUGS", ".", "items", "(", ")", "}", "return", "slugs_to_kinds", ".", "get", "(", "self", ".", "kind_slug", ",", ...
We'll have a kind_slug like 'movies'. We need to translate that into a work `kind` like 'movie'.
[ "We", "ll", "have", "a", "kind_slug", "like", "movies", ".", "We", "need", "to", "translate", "that", "into", "a", "work", "kind", "like", "movie", "." ]
python
train
39.571429
Terrance/SkPy
skpy/conn.py
https://github.com/Terrance/SkPy/blob/0f9489c94e8ec4d3effab4314497428872a80ad1/skpy/conn.py#L312-L327
def writeToken(self): """ Store details of the current connection in the named file. This can be used by :meth:`readToken` to re-authenticate at a later time. """ # Write token file privately. with os.fdopen(os.open(self.tokenFile, os.O_WRONLY | os.O_CREAT, 0o600), "w") ...
[ "def", "writeToken", "(", "self", ")", ":", "# Write token file privately.", "with", "os", ".", "fdopen", "(", "os", ".", "open", "(", "self", ".", "tokenFile", ",", "os", ".", "O_WRONLY", "|", "os", ".", "O_CREAT", ",", "0o600", ")", ",", "\"w\"", ")"...
Store details of the current connection in the named file. This can be used by :meth:`readToken` to re-authenticate at a later time.
[ "Store", "details", "of", "the", "current", "connection", "in", "the", "named", "file", "." ]
python
test
47.75
synw/dataswim
dataswim/data/clean.py
https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/clean.py#L345-L365
def strip(self, col: str): """ Remove leading and trailing white spaces in a column's values :param col: name of the column :type col: str :example: ``ds.strip("mycol")`` """ def remove_ws(row): val = str(row[col]) if " " in val.startswit...
[ "def", "strip", "(", "self", ",", "col", ":", "str", ")", ":", "def", "remove_ws", "(", "row", ")", ":", "val", "=", "str", "(", "row", "[", "col", "]", ")", "if", "\" \"", "in", "val", ".", "startswith", "(", "\" \"", ")", ":", "row", "[", "...
Remove leading and trailing white spaces in a column's values :param col: name of the column :type col: str :example: ``ds.strip("mycol")``
[ "Remove", "leading", "and", "trailing", "white", "spaces", "in", "a", "column", "s", "values" ]
python
train
28.095238
SiLab-Bonn/pyBAR
pybar/scans/calibrate_hit_or.py
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/scans/calibrate_hit_or.py#L20-L148
def create_hitor_calibration(output_filename, plot_pixel_calibrations=False): '''Generating HitOr calibration file (_calibration.h5) from raw data file and plotting of calibration data. Parameters ---------- output_filename : string Input raw data file name. plot_pixel_calibrations :...
[ "def", "create_hitor_calibration", "(", "output_filename", ",", "plot_pixel_calibrations", "=", "False", ")", ":", "logging", ".", "info", "(", "'Analyze HitOR calibration data and plot results of %s'", ",", "output_filename", ")", "with", "AnalyzeRawData", "(", "raw_data_f...
Generating HitOr calibration file (_calibration.h5) from raw data file and plotting of calibration data. Parameters ---------- output_filename : string Input raw data file name. plot_pixel_calibrations : bool, iterable If True, genearating additional pixel calibration plots. If l...
[ "Generating", "HitOr", "calibration", "file", "(", "_calibration", ".", "h5", ")", "from", "raw", "data", "file", "and", "plotting", "of", "calibration", "data", ".", "Parameters", "----------", "output_filename", ":", "string", "Input", "raw", "data", "file", ...
python
train
83.51938
nion-software/nionswift
nion/swift/Facade.py
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/Facade.py#L1080-L1089
def set_dimensional_calibrations(self, dimensional_calibrations: typing.List[CalibrationModule.Calibration]) -> None: """Set the dimensional calibrations. :param dimensional_calibrations: A list of calibrations, must match the dimensions of the data. .. versionadded:: 1.0 Scriptable: ...
[ "def", "set_dimensional_calibrations", "(", "self", ",", "dimensional_calibrations", ":", "typing", ".", "List", "[", "CalibrationModule", ".", "Calibration", "]", ")", "->", "None", ":", "self", ".", "__data_item", ".", "set_dimensional_calibrations", "(", "dimensi...
Set the dimensional calibrations. :param dimensional_calibrations: A list of calibrations, must match the dimensions of the data. .. versionadded:: 1.0 Scriptable: Yes
[ "Set", "the", "dimensional", "calibrations", "." ]
python
train
40.6
bpython/curtsies
curtsies/events.py
https://github.com/bpython/curtsies/blob/223e42b97fbf6c86b479ed4f0963a067333c5a63/curtsies/events.py#L243-L260
def pp_event(seq): """Returns pretty representation of an Event or keypress""" if isinstance(seq, Event): return str(seq) # Get the original sequence back if seq is a pretty name already rev_curses = dict((v, k) for k, v in CURSES_NAMES.items()) rev_curtsies = dict((v, k) for k, v in CURTS...
[ "def", "pp_event", "(", "seq", ")", ":", "if", "isinstance", "(", "seq", ",", "Event", ")", ":", "return", "str", "(", "seq", ")", "# Get the original sequence back if seq is a pretty name already", "rev_curses", "=", "dict", "(", "(", "v", ",", "k", ")", "f...
Returns pretty representation of an Event or keypress
[ "Returns", "pretty", "representation", "of", "an", "Event", "or", "keypress" ]
python
train
30.833333
Alignak-monitoring/alignak
alignak/objects/schedulingitem.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L2562-L2610
def create_business_rules(self, hosts, services, hostgroups, servicegroups, macromodulations, timeperiods, running=False): # pylint: disable=too-many-locals """Create business rules if necessary (cmd contains bp_rule) :param hosts: Hosts object to look for objects ...
[ "def", "create_business_rules", "(", "self", ",", "hosts", ",", "services", ",", "hostgroups", ",", "servicegroups", ",", "macromodulations", ",", "timeperiods", ",", "running", "=", "False", ")", ":", "# pylint: disable=too-many-locals", "cmdcall", "=", "getattr", ...
Create business rules if necessary (cmd contains bp_rule) :param hosts: Hosts object to look for objects :type hosts: alignak.objects.host.Hosts :param services: Services object to look for objects :type services: alignak.objects.service.Services :param running: flag used in eva...
[ "Create", "business", "rules", "if", "necessary", "(", "cmd", "contains", "bp_rule", ")" ]
python
train
44.244898
Gandi/gandi.cli
gandi/cli/commands/mail.py
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/mail.py#L140-L158
def purge(gandi, email, background, force, alias): """Purge a mailbox.""" login, domain = email if alias: if not force: proceed = click.confirm('Are you sure to purge all aliases for ' 'mailbox %s@%s ?' % (login, domain)) if not proceed: ...
[ "def", "purge", "(", "gandi", ",", "email", ",", "background", ",", "force", ",", "alias", ")", ":", "login", ",", "domain", "=", "email", "if", "alias", ":", "if", "not", "force", ":", "proceed", "=", "click", ".", "confirm", "(", "'Are you sure to pu...
Purge a mailbox.
[ "Purge", "a", "mailbox", "." ]
python
train
35.421053
guyzmo/git-repo
git_repo/services/service.py
https://github.com/guyzmo/git-repo/blob/2974c3f52bc64fa8a467ac2b0e9a485ba7ed333b/git_repo/services/service.py#L340-L352
def fetch(self, remote, branch, local_branch = None, force=False): '''Pull a repository :param remote: git-remote instance :param branch: name of the branch to pull ''' pb = ProgressBar() pb.setup(self.name) if local_branch: branch = ':'.join([branch,...
[ "def", "fetch", "(", "self", ",", "remote", ",", "branch", ",", "local_branch", "=", "None", ",", "force", "=", "False", ")", ":", "pb", "=", "ProgressBar", "(", ")", "pb", ".", "setup", "(", "self", ".", "name", ")", "if", "local_branch", ":", "br...
Pull a repository :param remote: git-remote instance :param branch: name of the branch to pull
[ "Pull", "a", "repository", ":", "param", "remote", ":", "git", "-", "remote", "instance", ":", "param", "branch", ":", "name", "of", "the", "branch", "to", "pull" ]
python
train
32
spyder-ide/spyder
spyder/plugins/plots/widgets/figurebrowser.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/plots/widgets/figurebrowser.py#L698-L704
def set_current_thumbnail(self, thumbnail): """Set the currently selected thumbnail.""" self.current_thumbnail = thumbnail self.figure_viewer.load_figure( thumbnail.canvas.fig, thumbnail.canvas.fmt) for thumbnail in self._thumbnails: thumbnail.highlight_canvas...
[ "def", "set_current_thumbnail", "(", "self", ",", "thumbnail", ")", ":", "self", ".", "current_thumbnail", "=", "thumbnail", "self", ".", "figure_viewer", ".", "load_figure", "(", "thumbnail", ".", "canvas", ".", "fig", ",", "thumbnail", ".", "canvas", ".", ...
Set the currently selected thumbnail.
[ "Set", "the", "currently", "selected", "thumbnail", "." ]
python
train
50.142857
lablup/backend.ai-client-py
src/ai/backend/client/cli/admin/images.py
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/cli/admin/images.py#L72-L83
def dealias_image(alias): '''Remove an image alias.''' with Session() as session: try: result = session.Image.dealiasImage(alias) except Exception as e: print_error(e) sys.exit(1) if result['ok']: print("alias {0} removed.".format(alias)) ...
[ "def", "dealias_image", "(", "alias", ")", ":", "with", "Session", "(", ")", "as", "session", ":", "try", ":", "result", "=", "session", ".", "Image", ".", "dealiasImage", "(", "alias", ")", "except", "Exception", "as", "e", ":", "print_error", "(", "e...
Remove an image alias.
[ "Remove", "an", "image", "alias", "." ]
python
train
29.5
wbond/asn1crypto
asn1crypto/keys.py
https://github.com/wbond/asn1crypto/blob/ecda20176f55d37021cbca1f6da9083a8e491197/asn1crypto/keys.py#L523-L588
def wrap(cls, private_key, algorithm): """ Wraps a private key in a PrivateKeyInfo structure :param private_key: A byte string or Asn1Value object of the private key :param algorithm: A unicode string of "rsa", "dsa" or "ec" :return: A Priva...
[ "def", "wrap", "(", "cls", ",", "private_key", ",", "algorithm", ")", ":", "if", "not", "isinstance", "(", "private_key", ",", "byte_cls", ")", "and", "not", "isinstance", "(", "private_key", ",", "Asn1Value", ")", ":", "raise", "TypeError", "(", "unwrap",...
Wraps a private key in a PrivateKeyInfo structure :param private_key: A byte string or Asn1Value object of the private key :param algorithm: A unicode string of "rsa", "dsa" or "ec" :return: A PrivateKeyInfo object
[ "Wraps", "a", "private", "key", "in", "a", "PrivateKeyInfo", "structure" ]
python
train
35.166667
zooniverse/panoptes-python-client
panoptes_client/collection.py
https://github.com/zooniverse/panoptes-python-client/blob/138d93cb03378501a8d349428e381ad73f928680/panoptes_client/collection.py#L28-L46
def find(cls, id='', slug=None): """ Similar to :py:meth:`.PanoptesObject.find`, but allows lookup by slug as well as ID. Examples:: collection_1234 = Collection.find(1234) my_collection = Collection.find(slug="example/my-collection") """ if not...
[ "def", "find", "(", "cls", ",", "id", "=", "''", ",", "slug", "=", "None", ")", ":", "if", "not", "id", "and", "not", "slug", ":", "return", "None", "try", ":", "return", "cls", ".", "where", "(", "id", "=", "id", ",", "slug", "=", "slug", ")...
Similar to :py:meth:`.PanoptesObject.find`, but allows lookup by slug as well as ID. Examples:: collection_1234 = Collection.find(1234) my_collection = Collection.find(slug="example/my-collection")
[ "Similar", "to", ":", "py", ":", "meth", ":", ".", "PanoptesObject", ".", "find", "but", "allows", "lookup", "by", "slug", "as", "well", "as", "ID", "." ]
python
train
29.789474
akatrevorjay/mainline
mainline/di.py
https://github.com/akatrevorjay/mainline/blob/8aa7f6ef6cad4051fcd5f8d43d2ba8cdad681986/mainline/di.py#L93-L111
def iresolve(self, *keys): ''' Iterates over resolved instances for given provider keys. :param keys: Provider keys :type keys: tuple :return: Iterator of resolved instances :rtype: generator ''' for key in keys: missing = self.get_missing_dep...
[ "def", "iresolve", "(", "self", ",", "*", "keys", ")", ":", "for", "key", "in", "keys", ":", "missing", "=", "self", ".", "get_missing_deps", "(", "key", ")", "if", "missing", ":", "raise", "UnresolvableError", "(", "\"Missing dependencies for %s: %s\"", "%"...
Iterates over resolved instances for given provider keys. :param keys: Provider keys :type keys: tuple :return: Iterator of resolved instances :rtype: generator
[ "Iterates", "over", "resolved", "instances", "for", "given", "provider", "keys", "." ]
python
train
32.210526