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
keleshev/schema
schema.py
https://github.com/keleshev/schema/blob/4a0bf6f509e6b69956a8f2fd4e1c3873fc419be8/schema.py#L421-L489
def json_schema(self, schema_id=None, is_main_schema=True): """Generate a draft-07 JSON schema dict representing the Schema. This method can only be called when the Schema's value is a dict. This method must be called with a schema_id. Calling it without one is used in a recursive contex...
[ "def", "json_schema", "(", "self", ",", "schema_id", "=", "None", ",", "is_main_schema", "=", "True", ")", ":", "Schema", "=", "self", ".", "__class__", "s", "=", "self", ".", "_schema", "i", "=", "self", ".", "_ignore_extra_keys", "flavor", "=", "_prior...
Generate a draft-07 JSON schema dict representing the Schema. This method can only be called when the Schema's value is a dict. This method must be called with a schema_id. Calling it without one is used in a recursive context for sub schemas.
[ "Generate", "a", "draft", "-", "07", "JSON", "schema", "dict", "representing", "the", "Schema", ".", "This", "method", "can", "only", "be", "called", "when", "the", "Schema", "s", "value", "is", "a", "dict", ".", "This", "method", "must", "be", "called",...
python
train
37.565217
Capitains/MyCapytain
MyCapytain/common/metadata.py
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/metadata.py#L235-L246
def getOr(subject, predicate, *args, **kwargs): """ Retrieve a metadata node or generate a new one :param subject: Subject to which the metadata node should be connected :param predicate: Predicate by which the metadata node should be connected :return: Metadata for given node :...
[ "def", "getOr", "(", "subject", ",", "predicate", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "(", "subject", ",", "predicate", ",", "None", ")", "in", "get_graph", "(", ")", ":", "return", "Metadata", "(", "node", "=", "get_graph", ...
Retrieve a metadata node or generate a new one :param subject: Subject to which the metadata node should be connected :param predicate: Predicate by which the metadata node should be connected :return: Metadata for given node :rtype: Metadata
[ "Retrieve", "a", "metadata", "node", "or", "generate", "a", "new", "one" ]
python
train
43.083333
opencobra/cobrapy
cobra/core/dictlist.py
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/dictlist.py#L345-L357
def pop(self, *args): """remove and return item at index (default last).""" value = list.pop(self, *args) index = self._dict.pop(value.id) # If the pop occured from a location other than the end of the list, # we will need to subtract 1 from every entry afterwards if len(...
[ "def", "pop", "(", "self", ",", "*", "args", ")", ":", "value", "=", "list", ".", "pop", "(", "self", ",", "*", "args", ")", "index", "=", "self", ".", "_dict", ".", "pop", "(", "value", ".", "id", ")", "# If the pop occured from a location other than ...
remove and return item at index (default last).
[ "remove", "and", "return", "item", "at", "index", "(", "default", "last", ")", "." ]
python
valid
41.692308
saltstack/salt
salt/cloud/clouds/msazure.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/msazure.py#L1597-L1628
def delete_disk(kwargs=None, conn=None, call=None): ''' .. versionadded:: 2015.8.0 Delete a specific disk associated with the account CLI Examples: .. code-block:: bash salt-cloud -f delete_disk my-azure name=my_disk salt-cloud -f delete_disk my-azure name=my_disk delete_vhd=True...
[ "def", "delete_disk", "(", "kwargs", "=", "None", ",", "conn", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The delete_disk function must be called with -f or --function.'", ")", "if...
.. versionadded:: 2015.8.0 Delete a specific disk associated with the account CLI Examples: .. code-block:: bash salt-cloud -f delete_disk my-azure name=my_disk salt-cloud -f delete_disk my-azure name=my_disk delete_vhd=True
[ "..", "versionadded", "::", "2015", ".", "8", ".", "0" ]
python
train
28.8125
astropy/photutils
photutils/aperture/bounding_box.py
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/aperture/bounding_box.py#L149-L157
def slices(self): """ The bounding box as a tuple of `slice` objects. The slice tuple is in numpy axis order (i.e. ``(y, x)``) and therefore can be used to slice numpy arrays. """ return (slice(self.iymin, self.iymax), slice(self.ixmin, self.ixmax))
[ "def", "slices", "(", "self", ")", ":", "return", "(", "slice", "(", "self", ".", "iymin", ",", "self", ".", "iymax", ")", ",", "slice", "(", "self", ".", "ixmin", ",", "self", ".", "ixmax", ")", ")" ]
The bounding box as a tuple of `slice` objects. The slice tuple is in numpy axis order (i.e. ``(y, x)``) and therefore can be used to slice numpy arrays.
[ "The", "bounding", "box", "as", "a", "tuple", "of", "slice", "objects", "." ]
python
train
32.333333
wglass/lighthouse
lighthouse/pluggable.py
https://github.com/wglass/lighthouse/blob/f4ce6550895acc31e433ede0c05d366718a3ffe5/lighthouse/pluggable.py#L36-L72
def get_installed_classes(cls): """ Iterates over installed plugins associated with the `entry_point` and returns a dictionary of viable ones keyed off of their names. A viable installed plugin is one that is both loadable *and* a subclass of the Pluggable subclass in question. ...
[ "def", "get_installed_classes", "(", "cls", ")", ":", "installed_classes", "=", "{", "}", "for", "entry_point", "in", "pkg_resources", ".", "iter_entry_points", "(", "cls", ".", "entry_point", ")", ":", "try", ":", "plugin", "=", "entry_point", ".", "load", ...
Iterates over installed plugins associated with the `entry_point` and returns a dictionary of viable ones keyed off of their names. A viable installed plugin is one that is both loadable *and* a subclass of the Pluggable subclass in question.
[ "Iterates", "over", "installed", "plugins", "associated", "with", "the", "entry_point", "and", "returns", "a", "dictionary", "of", "viable", "ones", "keyed", "off", "of", "their", "names", "." ]
python
train
35.864865
mobinrg/rpi_spark_drives
JMRPiSpark/Drives/Key/RPiKeyButtons.py
https://github.com/mobinrg/rpi_spark_drives/blob/e1602d8268a5ef48e9e0a8b37de89e0233f946ea/JMRPiSpark/Drives/Key/RPiKeyButtons.py#L161-L189
def configKeyButtons( self, enableButtons = [], bounceTime = DEF_BOUNCE_TIME_NORMAL, pullUpDown = GPIO.PUD_UP, event = GPIO.BOTH ): """! \~english Config multi key buttons IO and event on same time @param enableButtons: an array of key button configs. eg. <br> [{ "id":BU...
[ "def", "configKeyButtons", "(", "self", ",", "enableButtons", "=", "[", "]", ",", "bounceTime", "=", "DEF_BOUNCE_TIME_NORMAL", ",", "pullUpDown", "=", "GPIO", ".", "PUD_UP", ",", "event", "=", "GPIO", ".", "BOTH", ")", ":", "for", "key", "in", "enableButto...
! \~english Config multi key buttons IO and event on same time @param enableButtons: an array of key button configs. eg. <br> [{ "id":BUTTON_ACT_A, "callback": aCallbackFun }, ... ] @param bounceTime: Default set to DEF_BOUNCE_TIME_NORMAL @param pullUpDown: Defau...
[ "!", "\\", "~english", "Config", "multi", "key", "buttons", "IO", "and", "event", "on", "same", "time" ]
python
train
42.586207
erinxocon/spotify-local
src/spotify_local/core.py
https://github.com/erinxocon/spotify-local/blob/8188eef221e3d8b9f408ff430d80e74560360459/src/spotify_local/core.py#L94-L102
def remove_all_listeners(self, event=None): """Remove all functions for all events, or one event if one is specifed. :param event: Optional event you wish to remove all functions from """ if event is not None: self._registered_events[event] = OrderedDict() else: ...
[ "def", "remove_all_listeners", "(", "self", ",", "event", "=", "None", ")", ":", "if", "event", "is", "not", "None", ":", "self", ".", "_registered_events", "[", "event", "]", "=", "OrderedDict", "(", ")", "else", ":", "self", ".", "_registered_events", ...
Remove all functions for all events, or one event if one is specifed. :param event: Optional event you wish to remove all functions from
[ "Remove", "all", "functions", "for", "all", "events", "or", "one", "event", "if", "one", "is", "specifed", "." ]
python
train
41.111111
rwl/godot
godot/xdot_parser.py
https://github.com/rwl/godot/blob/013687c9e8983d2aa2ceebb8a76c5c4f1e37c90f/godot/xdot_parser.py#L354-L360
def proc_polyline(self, tokens): """ Returns the components of a polyline. """ pts = [(p["x"], p["y"]) for p in tokens["points"]] component = Polyline(pen=self.pen, points=pts) return component
[ "def", "proc_polyline", "(", "self", ",", "tokens", ")", ":", "pts", "=", "[", "(", "p", "[", "\"x\"", "]", ",", "p", "[", "\"y\"", "]", ")", "for", "p", "in", "tokens", "[", "\"points\"", "]", "]", "component", "=", "Polyline", "(", "pen", "=", ...
Returns the components of a polyline.
[ "Returns", "the", "components", "of", "a", "polyline", "." ]
python
test
31.571429
bharadwaj-raju/libdesktop
libdesktop/wallpaper.py
https://github.com/bharadwaj-raju/libdesktop/blob/4d6b815755c76660b6ef4d2db6f54beff38c0db7/libdesktop/wallpaper.py#L241-L462
def set_wallpaper(image): '''Set the desktop wallpaper. Sets the desktop wallpaper to an image. Args: image (str): The path to the image to be set as wallpaper. ''' desktop_env = system.get_name() if desktop_env in ['gnome', 'unity', 'cinnamon', 'pantheon', 'mate']: uri = 'file://%s' % image SCHEMA = ...
[ "def", "set_wallpaper", "(", "image", ")", ":", "desktop_env", "=", "system", ".", "get_name", "(", ")", "if", "desktop_env", "in", "[", "'gnome'", ",", "'unity'", ",", "'cinnamon'", ",", "'pantheon'", ",", "'mate'", "]", ":", "uri", "=", "'file://%s'", ...
Set the desktop wallpaper. Sets the desktop wallpaper to an image. Args: image (str): The path to the image to be set as wallpaper.
[ "Set", "the", "desktop", "wallpaper", "." ]
python
train
25.166667
gbowerman/azurerm
azurerm/networkrp.py
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L643-L657
def list_vnets(access_token, subscription_id): '''List the VNETs in a subscription . Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON body of VNets list with properties. ''' endpoint = '...
[ "def", "list_vnets", "(", "access_token", ",", "subscription_id", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/providers/Microsoft.Network/'", ",", "'/virtualNetworks?a...
List the VNETs in a subscription . Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON body of VNets list with properties.
[ "List", "the", "VNETs", "in", "a", "subscription", "." ]
python
train
37.466667
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_0/location/location_client.py
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/location/location_client.py#L72-L90
def get_resource_area_by_host(self, area_id, host_id): """GetResourceAreaByHost. [Preview API] :param str area_id: :param str host_id: :rtype: :class:`<ResourceAreaInfo> <azure.devops.v5_0.location.models.ResourceAreaInfo>` """ route_values = {} if area_id...
[ "def", "get_resource_area_by_host", "(", "self", ",", "area_id", ",", "host_id", ")", ":", "route_values", "=", "{", "}", "if", "area_id", "is", "not", "None", ":", "route_values", "[", "'areaId'", "]", "=", "self", ".", "_serialize", ".", "url", "(", "'...
GetResourceAreaByHost. [Preview API] :param str area_id: :param str host_id: :rtype: :class:`<ResourceAreaInfo> <azure.devops.v5_0.location.models.ResourceAreaInfo>`
[ "GetResourceAreaByHost", ".", "[", "Preview", "API", "]", ":", "param", "str", "area_id", ":", ":", "param", "str", "host_id", ":", ":", "rtype", ":", ":", "class", ":", "<ResourceAreaInfo", ">", "<azure", ".", "devops", ".", "v5_0", ".", "location", "."...
python
train
48.526316
python-cmd2/cmd2
cmd2/cmd2.py
https://github.com/python-cmd2/cmd2/blob/b22c0bd891ed08c8b09df56df9d91f48166a5e2a/cmd2/cmd2.py#L2811-L2814
def do_quit(self, _: argparse.Namespace) -> bool: """Exit this application""" self._should_quit = True return self._STOP_AND_EXIT
[ "def", "do_quit", "(", "self", ",", "_", ":", "argparse", ".", "Namespace", ")", "->", "bool", ":", "self", ".", "_should_quit", "=", "True", "return", "self", ".", "_STOP_AND_EXIT" ]
Exit this application
[ "Exit", "this", "application" ]
python
train
37.5
observerss/yamo
yamo/document.py
https://github.com/observerss/yamo/blob/ef0ab1ab7be2ecbc452d55ac9b367eb4c0d88646/yamo/document.py#L253-L263
def cached(cls, timeout=60, cache_none=False): """ Cache queries :param timeout: cache timeout :param cache_none: cache None result Usage:: >>> Model.cached(60).query({...}) """ return CachedModel(cls=cls, timeout=timeout, cache_none=cache_none)
[ "def", "cached", "(", "cls", ",", "timeout", "=", "60", ",", "cache_none", "=", "False", ")", ":", "return", "CachedModel", "(", "cls", "=", "cls", ",", "timeout", "=", "timeout", ",", "cache_none", "=", "cache_none", ")" ]
Cache queries :param timeout: cache timeout :param cache_none: cache None result Usage:: >>> Model.cached(60).query({...})
[ "Cache", "queries" ]
python
train
26.727273
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L178-L185
def setCamera(self, camera_name, bit_depth=16): ''' Args: camera_name (str): Name of the camera bit_depth (int): depth (bit) of the camera sensor ''' self.coeffs['name'] = camera_name self.coeffs['depth'] = bit_depth
[ "def", "setCamera", "(", "self", ",", "camera_name", ",", "bit_depth", "=", "16", ")", ":", "self", ".", "coeffs", "[", "'name'", "]", "=", "camera_name", "self", ".", "coeffs", "[", "'depth'", "]", "=", "bit_depth" ]
Args: camera_name (str): Name of the camera bit_depth (int): depth (bit) of the camera sensor
[ "Args", ":", "camera_name", "(", "str", ")", ":", "Name", "of", "the", "camera", "bit_depth", "(", "int", ")", ":", "depth", "(", "bit", ")", "of", "the", "camera", "sensor" ]
python
train
35
silenc3r/dikicli
dikicli/core.py
https://github.com/silenc3r/dikicli/blob/53721cdf75db04e2edca5ed3f99beae7c079d980/dikicli/core.py#L239-L266
def _cache_lookup(word, data_dir, native=False): """Checks if word is in cache. Parameters ---------- word : str Word to check in cache. data_dir : pathlib.Path Cache directory location. Returns ------- translation : str or None Translation of given word. ""...
[ "def", "_cache_lookup", "(", "word", ",", "data_dir", ",", "native", "=", "False", ")", ":", "trans_dir", "=", "\"translations\"", "if", "native", ":", "trans_dir", "+=", "\"_native\"", "logger", ".", "debug", "(", "\"Cache lookup: %s\"", ",", "word", ")", "...
Checks if word is in cache. Parameters ---------- word : str Word to check in cache. data_dir : pathlib.Path Cache directory location. Returns ------- translation : str or None Translation of given word.
[ "Checks", "if", "word", "is", "in", "cache", "." ]
python
train
28.535714
jtwhite79/pyemu
pyemu/pst/pst_handler.py
https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/pst/pst_handler.py#L2543-L2559
def less_than_obs_constraints(self): """get the names of the observations that are listed as less than inequality constraints. Zero- weighted obs are skipped Returns ------- pandas.Series : obsnme of obseravtions that are non-zero weighted less t...
[ "def", "less_than_obs_constraints", "(", "self", ")", ":", "obs", "=", "self", ".", "observation_data", "lt_obs", "=", "obs", ".", "loc", "[", "obs", ".", "apply", "(", "lambda", "x", ":", "self", ".", "_is_less_const", "(", "x", ".", "obgnme", ")", "a...
get the names of the observations that are listed as less than inequality constraints. Zero- weighted obs are skipped Returns ------- pandas.Series : obsnme of obseravtions that are non-zero weighted less than constraints
[ "get", "the", "names", "of", "the", "observations", "that", "are", "listed", "as", "less", "than", "inequality", "constraints", ".", "Zero", "-", "weighted", "obs", "are", "skipped" ]
python
train
32.470588
bugra/angel-list
angel/angel.py
https://github.com/bugra/angel-list/blob/75ac453e873727675ba18e1f45b5bc0cfda26fd7/angel/angel.py#L465-L472
def get_review_id(self, id_): """ Get a particular review id, independent from the user_id and startup_id """ return _get_request(_REVIEW_ID.format(c_api=_C_API_BEGINNING, api=_API_VERSION, ...
[ "def", "get_review_id", "(", "self", ",", "id_", ")", ":", "return", "_get_request", "(", "_REVIEW_ID", ".", "format", "(", "c_api", "=", "_C_API_BEGINNING", ",", "api", "=", "_API_VERSION", ",", "id_", "=", "id_", ",", "at", "=", "self", ".", "access_to...
Get a particular review id, independent from the user_id and startup_id
[ "Get", "a", "particular", "review", "id", "independent", "from", "the", "user_id", "and", "startup_id" ]
python
train
52
juiceinc/recipe
recipe/shelf.py
https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L669-L702
def find(self, obj, filter_to_class=Ingredient, constructor=None): """ Find an Ingredient, optionally using the shelf. :param obj: A string or Ingredient :param filter_to_class: The Ingredient subclass that obj must be an instance of :param constructor: An optional call...
[ "def", "find", "(", "self", ",", "obj", ",", "filter_to_class", "=", "Ingredient", ",", "constructor", "=", "None", ")", ":", "if", "callable", "(", "constructor", ")", ":", "obj", "=", "constructor", "(", "obj", ",", "shelf", "=", "self", ")", "if", ...
Find an Ingredient, optionally using the shelf. :param obj: A string or Ingredient :param filter_to_class: The Ingredient subclass that obj must be an instance of :param constructor: An optional callable for building Ingredients from obj :return: An Ingredient of subcl...
[ "Find", "an", "Ingredient", "optionally", "using", "the", "shelf", "." ]
python
train
35.029412
hydpy-dev/hydpy
hydpy/core/netcdftools.py
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1396-L1399
def subdevicenames(self) -> Tuple[str, ...]: """A |tuple| containing the device names.""" self: NetCDFVariableBase return tuple(self.sequences.keys())
[ "def", "subdevicenames", "(", "self", ")", "->", "Tuple", "[", "str", ",", "...", "]", ":", "self", ":", "NetCDFVariableBase", "return", "tuple", "(", "self", ".", "sequences", ".", "keys", "(", ")", ")" ]
A |tuple| containing the device names.
[ "A", "|tuple|", "containing", "the", "device", "names", "." ]
python
train
42.75
cga-harvard/Hypermap-Registry
hypermap/search/pycsw_plugin.py
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L190-L194
def query_source(self, source): """ Query by source """ return self._get_repo_filter(Layer.objects).filter(url=source)
[ "def", "query_source", "(", "self", ",", "source", ")", ":", "return", "self", ".", "_get_repo_filter", "(", "Layer", ".", "objects", ")", ".", "filter", "(", "url", "=", "source", ")" ]
Query by source
[ "Query", "by", "source" ]
python
train
29.2
elastic/elasticsearch-dsl-py
examples/alias_migration.py
https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/examples/alias_migration.py#L70-L106
def migrate(move_data=True, update_alias=True): """ Upgrade function that creates a new index for the data. Optionally it also can (and by default will) reindex previous copy of the data into the new index (specify ``move_data=False`` to skip this step) and update the alias to point to the latest in...
[ "def", "migrate", "(", "move_data", "=", "True", ",", "update_alias", "=", "True", ")", ":", "# construct a new index name by appending current timestamp", "next_index", "=", "PATTERN", ".", "replace", "(", "'*'", ",", "datetime", ".", "now", "(", ")", ".", "str...
Upgrade function that creates a new index for the data. Optionally it also can (and by default will) reindex previous copy of the data into the new index (specify ``move_data=False`` to skip this step) and update the alias to point to the latest index (set ``update_alias=False`` to skip). Note that whi...
[ "Upgrade", "function", "that", "creates", "a", "new", "index", "for", "the", "data", ".", "Optionally", "it", "also", "can", "(", "and", "by", "default", "will", ")", "reindex", "previous", "copy", "of", "the", "data", "into", "the", "new", "index", "(",...
python
train
40.702703
ceph/ceph-deploy
ceph_deploy/hosts/remotes.py
https://github.com/ceph/ceph-deploy/blob/86943fcc454cd4c99a86e3493e9e93a59c661fef/ceph_deploy/hosts/remotes.py#L14-L50
def platform_information(_linux_distribution=None): """ detect platform information from remote host """ linux_distribution = _linux_distribution or platform.linux_distribution distro, release, codename = linux_distribution() if not distro: distro, release, codename = parse_os_release() if n...
[ "def", "platform_information", "(", "_linux_distribution", "=", "None", ")", ":", "linux_distribution", "=", "_linux_distribution", "or", "platform", ".", "linux_distribution", "distro", ",", "release", ",", "codename", "=", "linux_distribution", "(", ")", "if", "no...
detect platform information from remote host
[ "detect", "platform", "information", "from", "remote", "host" ]
python
train
40.945946
HewlettPackard/python-hpOneView
hpOneView/resources/settings/backups.py
https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/settings/backups.py#L141-L155
def update_remote_archive(self, save_uri, timeout=-1): """ Saves a backup of the appliance to a previously-configured remote location. Args: save_uri (dict): The URI for saving the backup to a previously configured location. timeout: Timeout in seconds. W...
[ "def", "update_remote_archive", "(", "self", ",", "save_uri", ",", "timeout", "=", "-", "1", ")", ":", "return", "self", ".", "_client", ".", "update_with_zero_body", "(", "uri", "=", "save_uri", ",", "timeout", "=", "timeout", ")" ]
Saves a backup of the appliance to a previously-configured remote location. Args: save_uri (dict): The URI for saving the backup to a previously configured location. timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operatio...
[ "Saves", "a", "backup", "of", "the", "appliance", "to", "a", "previously", "-", "configured", "remote", "location", "." ]
python
train
39.6
gwpy/gwpy
gwpy/io/gwf.py
https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/io/gwf.py#L99-L127
def write_frames(filename, frames, compression=257, compression_level=6): """Write a list of frame objects to a file **Requires:** |LDAStools.frameCPP|_ Parameters ---------- filename : `str` path to write into frames : `list` of `LDAStools.frameCPP.FrameH` list of frames to w...
[ "def", "write_frames", "(", "filename", ",", "frames", ",", "compression", "=", "257", ",", "compression_level", "=", "6", ")", ":", "from", "LDAStools", "import", "frameCPP", "# open stream", "stream", "=", "open_gwf", "(", "filename", ",", "'w'", ")", "# w...
Write a list of frame objects to a file **Requires:** |LDAStools.frameCPP|_ Parameters ---------- filename : `str` path to write into frames : `list` of `LDAStools.frameCPP.FrameH` list of frames to write into file compression : `int`, optional enum value for compress...
[ "Write", "a", "list", "of", "frame", "objects", "to", "a", "file" ]
python
train
26.827586
PyThaiNLP/pythainlp
pythainlp/spell/pn.py
https://github.com/PyThaiNLP/pythainlp/blob/e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca/pythainlp/spell/pn.py#L138-L156
def spell(self, word: str) -> List[str]: """ Return a list of possible words, according to edit distance of 1 and 2, sorted by frequency of word occurrance in the spelling dictionary :param str word: A word to check its spelling """ if not word: return "" ...
[ "def", "spell", "(", "self", ",", "word", ":", "str", ")", "->", "List", "[", "str", "]", ":", "if", "not", "word", ":", "return", "\"\"", "candidates", "=", "(", "self", ".", "known", "(", "[", "word", "]", ")", "or", "self", ".", "known", "("...
Return a list of possible words, according to edit distance of 1 and 2, sorted by frequency of word occurrance in the spelling dictionary :param str word: A word to check its spelling
[ "Return", "a", "list", "of", "possible", "words", "according", "to", "edit", "distance", "of", "1", "and", "2", "sorted", "by", "frequency", "of", "word", "occurrance", "in", "the", "spelling", "dictionary" ]
python
train
28.789474
xhtml2pdf/xhtml2pdf
xhtml2pdf/reportlab_paragraph.py
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/reportlab_paragraph.py#L1657-L1675
def getPlainText(self, identify=None): """ Convenience function for templates which want access to the raw text, without XML tags. """ frags = getattr(self, 'frags', None) if frags: plains = [] for frag in frags: if hasattr(frag, '...
[ "def", "getPlainText", "(", "self", ",", "identify", "=", "None", ")", ":", "frags", "=", "getattr", "(", "self", ",", "'frags'", ",", "None", ")", "if", "frags", ":", "plains", "=", "[", "]", "for", "frag", "in", "frags", ":", "if", "hasattr", "("...
Convenience function for templates which want access to the raw text, without XML tags.
[ "Convenience", "function", "for", "templates", "which", "want", "access", "to", "the", "raw", "text", "without", "XML", "tags", "." ]
python
train
29.789474
pmacosta/ptrie
ptrie/ptrie.py
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L937-L975
def get_subtree(self, name): # noqa: D302 r""" Get all node names in a sub-tree. :param name: Sub-tree root node name :type name: :ref:`NodeName` :rtype: list of :ref:`NodeName` :raises: * RuntimeError (Argument \`name\` is not valid) * RuntimeErro...
[ "def", "get_subtree", "(", "self", ",", "name", ")", ":", "# noqa: D302", "if", "self", ".", "_validate_node_name", "(", "name", ")", ":", "raise", "RuntimeError", "(", "\"Argument `name` is not valid\"", ")", "self", ".", "_node_in_tree", "(", "name", ")", "r...
r""" Get all node names in a sub-tree. :param name: Sub-tree root node name :type name: :ref:`NodeName` :rtype: list of :ref:`NodeName` :raises: * RuntimeError (Argument \`name\` is not valid) * RuntimeError (Node *[name]* not in tree) Using the sa...
[ "r", "Get", "all", "node", "names", "in", "a", "sub", "-", "tree", "." ]
python
train
30.923077
kelproject/pykube
pykube/config.py
https://github.com/kelproject/pykube/blob/e8a46298a592ad9037587afb707ac75b3114eff9/pykube/config.py#L260-L269
def filename(self): """ Returns the provided data as a file location. """ if self._filename: return self._filename else: with tempfile.NamedTemporaryFile(delete=False) as f: f.write(self._bytes) return f.name
[ "def", "filename", "(", "self", ")", ":", "if", "self", ".", "_filename", ":", "return", "self", ".", "_filename", "else", ":", "with", "tempfile", ".", "NamedTemporaryFile", "(", "delete", "=", "False", ")", "as", "f", ":", "f", ".", "write", "(", "...
Returns the provided data as a file location.
[ "Returns", "the", "provided", "data", "as", "a", "file", "location", "." ]
python
train
29.1
gwastro/pycbc-glue
pycbc_glue/ligolw/lsctables.py
https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/ligolw/lsctables.py#L4278-L4284
def apply_to_segmentlist(self, seglist): """ Apply our low and high windows to the segments in a segmentlist. """ for i, seg in enumerate(seglist): seglist[i] = seg.__class__(seg[0] - self.low_window, seg[1] + self.high_window)
[ "def", "apply_to_segmentlist", "(", "self", ",", "seglist", ")", ":", "for", "i", ",", "seg", "in", "enumerate", "(", "seglist", ")", ":", "seglist", "[", "i", "]", "=", "seg", ".", "__class__", "(", "seg", "[", "0", "]", "-", "self", ".", "low_win...
Apply our low and high windows to the segments in a segmentlist.
[ "Apply", "our", "low", "and", "high", "windows", "to", "the", "segments", "in", "a", "segmentlist", "." ]
python
train
33.428571
ASKIDA/Selenium2LibraryExtension
src/Selenium2LibraryExtension/keywords/__init__.py
https://github.com/ASKIDA/Selenium2LibraryExtension/blob/5ca3fa776063c6046dff317cb2575e4772d7541f/src/Selenium2LibraryExtension/keywords/__init__.py#L332-L339
def element_focus_should_be_set(self, locator): """Verifies the element identified by `locator` has focus. | *Argument* | *Description* | *Example* | | locator | Selenium 2 element locator | id=my_id |""" self._info("Verifying element '%s' focus is set" % locator) self._check_element_focus(True, locator)
[ "def", "element_focus_should_be_set", "(", "self", ",", "locator", ")", ":", "self", ".", "_info", "(", "\"Verifying element '%s' focus is set\"", "%", "locator", ")", "self", ".", "_check_element_focus", "(", "True", ",", "locator", ")" ]
Verifies the element identified by `locator` has focus. | *Argument* | *Description* | *Example* | | locator | Selenium 2 element locator | id=my_id |
[ "Verifies", "the", "element", "identified", "by", "locator", "has", "focus", "." ]
python
train
38.75
iterative/dvc
dvc/version.py
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/version.py#L13-L27
def _generate_version(base_version): """Generate a version with information about the git repository""" pkg_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) if not _is_git_repo(pkg_dir) or not _have_git(): return base_version if _is_release(pkg_dir, base_version) and not _is_d...
[ "def", "_generate_version", "(", "base_version", ")", ":", "pkg_dir", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", ")", "if", "not", "_is_git_repo", ...
Generate a version with information about the git repository
[ "Generate", "a", "version", "with", "information", "about", "the", "git", "repository" ]
python
train
37.333333
Azure/azure-sdk-for-python
azure-mgmt-reservations/azure/mgmt/reservations/operations/reservation_operations.py
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-reservations/azure/mgmt/reservations/operations/reservation_operations.py#L194-L243
def merge( self, reservation_order_id, sources=None, custom_headers=None, raw=False, polling=True, **operation_config): """Merges two `Reservation`s. Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. ...
[ "def", "merge", "(", "self", ",", "reservation_order_id", ",", "sources", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".",...
Merges two `Reservation`s. Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. :param reservation_order_id: Order Id of the reservation :type reservation_order_id: str :param sources: Format of the resource...
[ "Merges", "two", "Reservation", "s", "." ]
python
test
47.68
elastic/apm-agent-python
elasticapm/instrumentation/packages/base.py
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/instrumentation/packages/base.py#L143-L157
def mutate_unsampled_call_args(self, module, method, wrapped, instance, args, kwargs, transaction): """ Method called for unsampled wrapped calls. This can e.g. be used to add traceparent headers to the underlying http call for HTTP instrumentations. :param module: :param method...
[ "def", "mutate_unsampled_call_args", "(", "self", ",", "module", ",", "method", ",", "wrapped", ",", "instance", ",", "args", ",", "kwargs", ",", "transaction", ")", ":", "return", "args", ",", "kwargs" ]
Method called for unsampled wrapped calls. This can e.g. be used to add traceparent headers to the underlying http call for HTTP instrumentations. :param module: :param method: :param wrapped: :param instance: :param args: :param kwargs: :param transactio...
[ "Method", "called", "for", "unsampled", "wrapped", "calls", ".", "This", "can", "e", ".", "g", ".", "be", "used", "to", "add", "traceparent", "headers", "to", "the", "underlying", "http", "call", "for", "HTTP", "instrumentations", "." ]
python
train
32.333333
Alignak-monitoring/alignak
alignak/daterange.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L993-L1042
def get_start_and_end_time(self, ref=None): """Specific function to get start time and end time for MonthDayDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int) """ now = time.localtime(ref) ...
[ "def", "get_start_and_end_time", "(", "self", ",", "ref", "=", "None", ")", ":", "now", "=", "time", ".", "localtime", "(", "ref", ")", "if", "self", ".", "syear", "==", "0", ":", "self", ".", "syear", "=", "now", ".", "tm_year", "month_start_id", "=...
Specific function to get start time and end time for MonthDayDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int)
[ "Specific", "function", "to", "get", "start", "time", "and", "end", "time", "for", "MonthDayDaterange" ]
python
train
36.72
juju/charm-helpers
charmhelpers/contrib/storage/linux/ceph.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L1351-L1365
def get_previous_request(rid): """Return the last ceph broker request sent on a given relation @param rid: Relation id to query for request """ request = None broker_req = relation_get(attribute='broker_req', rid=rid, unit=local_unit()) if broker_req: reque...
[ "def", "get_previous_request", "(", "rid", ")", ":", "request", "=", "None", "broker_req", "=", "relation_get", "(", "attribute", "=", "'broker_req'", ",", "rid", "=", "rid", ",", "unit", "=", "local_unit", "(", ")", ")", "if", "broker_req", ":", "request_...
Return the last ceph broker request sent on a given relation @param rid: Relation id to query for request
[ "Return", "the", "last", "ceph", "broker", "request", "sent", "on", "a", "given", "relation" ]
python
train
36.333333
Esri/ArcREST
src/arcrest/ags/server.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/server.py#L57-L74
def _validateurl(self, url): """assembles the server url""" parsed = urlparse(url) path = parsed.path.strip("/") if path: parts = path.split("/") url_types = ("admin", "manager", "rest") if any(i in parts for i in url_types): while part...
[ "def", "_validateurl", "(", "self", ",", "url", ")", ":", "parsed", "=", "urlparse", "(", "url", ")", "path", "=", "parsed", ".", "path", ".", "strip", "(", "\"/\"", ")", "if", "path", ":", "parts", "=", "path", ".", "split", "(", "\"/\"", ")", "...
assembles the server url
[ "assembles", "the", "server", "url" ]
python
train
39.444444
ThreatConnect-Inc/tcex
tcex/tcex_resources.py
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_resources.py#L1621-L1629
def indicator(self, data): """Update the request URI to include the Indicator for specific indicator retrieval. Args: data (string): The indicator value """ # handle hashes in form md5 : sha1 : sha256 data = self.get_first_hash(data) super(File, self).indicat...
[ "def", "indicator", "(", "self", ",", "data", ")", ":", "# handle hashes in form md5 : sha1 : sha256", "data", "=", "self", ".", "get_first_hash", "(", "data", ")", "super", "(", "File", ",", "self", ")", ".", "indicator", "(", "data", ")" ]
Update the request URI to include the Indicator for specific indicator retrieval. Args: data (string): The indicator value
[ "Update", "the", "request", "URI", "to", "include", "the", "Indicator", "for", "specific", "indicator", "retrieval", "." ]
python
train
35.555556
fhcrc/taxtastic
taxtastic/taxonomy.py
https://github.com/fhcrc/taxtastic/blob/4e874b7f2cc146178828bfba386314f8c342722b/taxtastic/taxonomy.py#L457-L481
def verify_rank_integrity(self, tax_id, rank, parent_id, children): """Confirm that for each node the parent ranks and children ranks are coherent """ def _lower(n1, n2): return self.ranks.index(n1) < self.ranks.index(n2) if rank not in self.ranks: raise...
[ "def", "verify_rank_integrity", "(", "self", ",", "tax_id", ",", "rank", ",", "parent_id", ",", "children", ")", ":", "def", "_lower", "(", "n1", ",", "n2", ")", ":", "return", "self", ".", "ranks", ".", "index", "(", "n1", ")", "<", "self", ".", "...
Confirm that for each node the parent ranks and children ranks are coherent
[ "Confirm", "that", "for", "each", "node", "the", "parent", "ranks", "and", "children", "ranks", "are", "coherent" ]
python
train
41.52
bachiraoun/pysimplelog
SimpleLog.py
https://github.com/bachiraoun/pysimplelog/blob/2681ed5b1b8d7e66c3fff3ec3cca2b14ac571238/SimpleLog.py#L1210-L1212
def warn(self, message, *args, **kwargs): """alias to message at warning level""" self.log("warn", message, *args, **kwargs)
[ "def", "warn", "(", "self", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "log", "(", "\"warn\"", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
alias to message at warning level
[ "alias", "to", "message", "at", "warning", "level" ]
python
train
46
opendatateam/udata
udata/utils.py
https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/utils.py#L145-L154
def to_iso(dt): ''' Format a date or datetime into an ISO-8601 string Support dates before 1900. ''' if isinstance(dt, datetime): return to_iso_datetime(dt) elif isinstance(dt, date): return to_iso_date(dt)
[ "def", "to_iso", "(", "dt", ")", ":", "if", "isinstance", "(", "dt", ",", "datetime", ")", ":", "return", "to_iso_datetime", "(", "dt", ")", "elif", "isinstance", "(", "dt", ",", "date", ")", ":", "return", "to_iso_date", "(", "dt", ")" ]
Format a date or datetime into an ISO-8601 string Support dates before 1900.
[ "Format", "a", "date", "or", "datetime", "into", "an", "ISO", "-", "8601", "string" ]
python
train
23.8
EntilZha/PyFunctional
functional/transformations.py
https://github.com/EntilZha/PyFunctional/blob/ac04e4a8552b0c464a7f492f7c9862424867b63e/functional/transformations.py#L526-L535
def count_by_key_impl(sequence): """ Implementation for count_by_key_t :param sequence: sequence of (key, value) pairs :return: counts by key """ counter = collections.Counter() for key, _ in sequence: counter[key] += 1 return six.viewitems(counter)
[ "def", "count_by_key_impl", "(", "sequence", ")", ":", "counter", "=", "collections", ".", "Counter", "(", ")", "for", "key", ",", "_", "in", "sequence", ":", "counter", "[", "key", "]", "+=", "1", "return", "six", ".", "viewitems", "(", "counter", ")"...
Implementation for count_by_key_t :param sequence: sequence of (key, value) pairs :return: counts by key
[ "Implementation", "for", "count_by_key_t", ":", "param", "sequence", ":", "sequence", "of", "(", "key", "value", ")", "pairs", ":", "return", ":", "counts", "by", "key" ]
python
train
28
chaoss/grimoirelab-sortinghat
sortinghat/cmd/autogender.py
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/autogender.py#L91-L146
def autogender(self, api_token=None, genderize_all=False): """Autocomplete gender information of unique identities. Autocomplete unique identities gender using genderize.io API. Only those unique identities without an assigned gender will be updated unless `genderize_all` option is give...
[ "def", "autogender", "(", "self", ",", "api_token", "=", "None", ",", "genderize_all", "=", "False", ")", ":", "name_cache", "=", "{", "}", "no_gender", "=", "not", "genderize_all", "pattern", "=", "re", ".", "compile", "(", "r\"(^\\w+)\\s\\w+\"", ")", "pr...
Autocomplete gender information of unique identities. Autocomplete unique identities gender using genderize.io API. Only those unique identities without an assigned gender will be updated unless `genderize_all` option is given.
[ "Autocomplete", "gender", "information", "of", "unique", "identities", "." ]
python
train
34.267857
onicagroup/runway
runway/commands/modules_command.py
https://github.com/onicagroup/runway/blob/3f3549ec3bf6e39b9f27d9738a1847f3a4369e7f/runway/commands/modules_command.py#L382-L394
def reverse_deployments(deployments=None): """Reverse deployments and the modules/regions in them.""" if deployments is None: deployments = [] reversed_deployments = [] for i in deployments[::-1]: deployment = copy.deepcopy(i) for config in ['modules'...
[ "def", "reverse_deployments", "(", "deployments", "=", "None", ")", ":", "if", "deployments", "is", "None", ":", "deployments", "=", "[", "]", "reversed_deployments", "=", "[", "]", "for", "i", "in", "deployments", "[", ":", ":", "-", "1", "]", ":", "d...
Reverse deployments and the modules/regions in them.
[ "Reverse", "deployments", "and", "the", "modules", "/", "regions", "in", "them", "." ]
python
train
39.846154
RediSearch/redisearch-py
redisearch/aggregation.py
https://github.com/RediSearch/redisearch-py/blob/f65d1dd078713cbe9b83584e86655a254d0531ab/redisearch/aggregation.py#L169-L182
def apply(self, **kwexpr): """ Specify one or more projection expressions to add to each result ### Parameters - **kwexpr**: One or more key-value pairs for a projection. The key is the alias for the projection, and the value is the projection expression itself,...
[ "def", "apply", "(", "self", ",", "*", "*", "kwexpr", ")", ":", "for", "alias", ",", "expr", "in", "kwexpr", ".", "items", "(", ")", ":", "self", ".", "_projections", ".", "append", "(", "[", "alias", ",", "expr", "]", ")", "return", "self" ]
Specify one or more projection expressions to add to each result ### Parameters - **kwexpr**: One or more key-value pairs for a projection. The key is the alias for the projection, and the value is the projection expression itself, for example `apply(square_root="sqrt(@foo)")`
[ "Specify", "one", "or", "more", "projection", "expressions", "to", "add", "to", "each", "result" ]
python
valid
34.357143
rsgalloway/grit
grit/repo/version.py
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/version.py#L193-L203
def save(self, msg=None): """ Modify item data and commit to repo. Git objects are immutable, to save means adding a new item :param msg: Commit message. """ if msg is None: msg = 'Saving %s' % self.name log.debug(msg) self.repo.addItem(self,...
[ "def", "save", "(", "self", ",", "msg", "=", "None", ")", ":", "if", "msg", "is", "None", ":", "msg", "=", "'Saving %s'", "%", "self", ".", "name", "log", ".", "debug", "(", "msg", ")", "self", ".", "repo", ".", "addItem", "(", "self", ",", "ms...
Modify item data and commit to repo. Git objects are immutable, to save means adding a new item :param msg: Commit message.
[ "Modify", "item", "data", "and", "commit", "to", "repo", ".", "Git", "objects", "are", "immutable", "to", "save", "means", "adding", "a", "new", "item" ]
python
train
28.636364
PhilippeFerreiraDeSousa/bitext-matching
lib/enpc_aligner/IBM2_func.py
https://github.com/PhilippeFerreiraDeSousa/bitext-matching/blob/195c3e98775cfa5e63e4bb0bb1da6f741880d980/lib/enpc_aligner/IBM2_func.py#L104-L131
def matrix( m, n, lst, m_text: list=None, n_text: list=None): """ m: row n: column lst: items >>> print(_matrix(2, 3, [(1, 1), (2, 3)])) |x| | | | | |x| """ fmt = "" if n_text: fmt += " {}\n".format(" ".join(n_text)) for ...
[ "def", "matrix", "(", "m", ",", "n", ",", "lst", ",", "m_text", ":", "list", "=", "None", ",", "n_text", ":", "list", "=", "None", ")", ":", "fmt", "=", "\"\"", "if", "n_text", ":", "fmt", "+=", "\" {}\\n\"", ".", "format", "(", "\" \"", ".",...
m: row n: column lst: items >>> print(_matrix(2, 3, [(1, 1), (2, 3)])) |x| | | | | |x|
[ "m", ":", "row", "n", ":", "column", "lst", ":", "items", ">>>", "print", "(", "_matrix", "(", "2", "3", "[", "(", "1", "1", ")", "(", "2", "3", ")", "]", "))", "|x|", "|", "|", "|", "|", "|x|" ]
python
train
20.75
Fantomas42/django-blog-zinnia
zinnia/views/mixins/callable_queryset.py
https://github.com/Fantomas42/django-blog-zinnia/blob/b4949304b104a8e1a7a7a0773cbfd024313c3a15/zinnia/views/mixins/callable_queryset.py#L13-L20
def get_queryset(self): """ Check that the queryset is defined and call it. """ if self.queryset is None: raise ImproperlyConfigured( "'%s' must define 'queryset'" % self.__class__.__name__) return self.queryset()
[ "def", "get_queryset", "(", "self", ")", ":", "if", "self", ".", "queryset", "is", "None", ":", "raise", "ImproperlyConfigured", "(", "\"'%s' must define 'queryset'\"", "%", "self", ".", "__class__", ".", "__name__", ")", "return", "self", ".", "queryset", "("...
Check that the queryset is defined and call it.
[ "Check", "that", "the", "queryset", "is", "defined", "and", "call", "it", "." ]
python
train
34.25
obulpathi/cdn-fastly-python
fastly/__init__.py
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L436-L439
def check_domain(self, service_id, version_number, name): """Checks the status of a domain's DNS record. Returns an array of 3 items. The first is the details for the domain. The second is the current CNAME of the domain. The third is a boolean indicating whether or not it has been properly setup to use Fastly.""" ...
[ "def", "check_domain", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/domain/%s/check\"", "%", "(", "service_id", ",", "version_number", ",", "name", ")", ")", ...
Checks the status of a domain's DNS record. Returns an array of 3 items. The first is the details for the domain. The second is the current CNAME of the domain. The third is a boolean indicating whether or not it has been properly setup to use Fastly.
[ "Checks", "the", "status", "of", "a", "domain", "s", "DNS", "record", ".", "Returns", "an", "array", "of", "3", "items", ".", "The", "first", "is", "the", "details", "for", "the", "domain", ".", "The", "second", "is", "the", "current", "CNAME", "of", ...
python
train
114.75
MrYsLab/pymata-aio
pymata_aio/pymata_iot.py
https://github.com/MrYsLab/pymata-aio/blob/015081a4628b9d47dfe3f8d6c698ff903f107810/pymata_aio/pymata_iot.py#L303-L318
async def get_pinstate_report(self, command): """ This method retrieves a Firmata pin_state report for a pin.. See: http://firmata.org/wiki/Protocol#Pin_State_Query :param command: {"method": "get_pin_state", "params": [PIN]} :returns: {"method": "get_pin_state_reply", "params"...
[ "async", "def", "get_pinstate_report", "(", "self", ",", "command", ")", ":", "pin", "=", "int", "(", "command", "[", "0", "]", ")", "value", "=", "await", "self", ".", "core", ".", "get_pin_state", "(", "pin", ")", "if", "value", ":", "reply", "=", ...
This method retrieves a Firmata pin_state report for a pin.. See: http://firmata.org/wiki/Protocol#Pin_State_Query :param command: {"method": "get_pin_state", "params": [PIN]} :returns: {"method": "get_pin_state_reply", "params": [PIN_NUMBER, PIN_MODE, PIN_STATE]}
[ "This", "method", "retrieves", "a", "Firmata", "pin_state", "report", "for", "a", "pin", ".." ]
python
train
41.8125
DLR-RM/RAFCON
source/rafcon/gui/helpers/label.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/helpers/label.py#L208-L217
def get_notebook_tab_title(notebook, page_num): """Helper function that gets a notebook's tab title given its page number :param notebook: The GTK notebook :param page_num: The page number of the tab, for which the title is required :return: The title of the tab """ child = notebook.get_nth_pag...
[ "def", "get_notebook_tab_title", "(", "notebook", ",", "page_num", ")", ":", "child", "=", "notebook", ".", "get_nth_page", "(", "page_num", ")", "tab_label_eventbox", "=", "notebook", ".", "get_tab_label", "(", "child", ")", "return", "get_widget_title", "(", "...
Helper function that gets a notebook's tab title given its page number :param notebook: The GTK notebook :param page_num: The page number of the tab, for which the title is required :return: The title of the tab
[ "Helper", "function", "that", "gets", "a", "notebook", "s", "tab", "title", "given", "its", "page", "number" ]
python
train
44.4
alex-kostirin/pyatomac
atomac/ldtpd/page_tab_list.py
https://github.com/alex-kostirin/pyatomac/blob/3f46f6feb4504315eec07abb18bb41be4d257aeb/atomac/ldtpd/page_tab_list.py#L73-L97
def selecttabindex(self, window_name, object_name, tab_index): """ Select tab based on index. @param window_name: Window name to type in, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to type i...
[ "def", "selecttabindex", "(", "self", ",", "window_name", ",", "object_name", ",", "tab_index", ")", ":", "children", "=", "self", ".", "_get_tab_children", "(", "window_name", ",", "object_name", ")", "length", "=", "len", "(", "children", ")", "if", "tab_i...
Select tab based on index. @param window_name: Window name to type in, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to type in, either full name, LDTP's name convention, or a Unix glob. @type...
[ "Select", "tab", "based", "on", "index", ".", "@param", "window_name", ":", "Window", "name", "to", "type", "in", "either", "full", "name", "LDTP", "s", "name", "convention", "or", "a", "Unix", "glob", ".", "@type", "window_name", ":", "string", "@param", ...
python
valid
38.4
hasgeek/coaster
coaster/sqlalchemy/mixins.py
https://github.com/hasgeek/coaster/blob/07f7eb5d5f516e22fa14fdf4dc70e0ae13ee398d/coaster/sqlalchemy/mixins.py#L396-L414
def make_name(self, reserved=[]): """ Autogenerates a :attr:`name` from the :attr:`title`. If the auto-generated name is already in use in this model, :meth:`make_name` tries again by suffixing numbers starting with 2 until an available name is found. :param reserved: List or se...
[ "def", "make_name", "(", "self", ",", "reserved", "=", "[", "]", ")", ":", "if", "self", ".", "title", ":", "if", "inspect", "(", "self", ")", ".", "has_identity", ":", "def", "checkused", "(", "c", ")", ":", "return", "bool", "(", "c", "in", "re...
Autogenerates a :attr:`name` from the :attr:`title`. If the auto-generated name is already in use in this model, :meth:`make_name` tries again by suffixing numbers starting with 2 until an available name is found. :param reserved: List or set of reserved names unavailable for use
[ "Autogenerates", "a", ":", "attr", ":", "name", "from", "the", ":", "attr", ":", "title", ".", "If", "the", "auto", "-", "generated", "name", "is", "already", "in", "use", "in", "this", "model", ":", "meth", ":", "make_name", "tries", "again", "by", ...
python
train
54.368421
Guake/guake
guake/guake_app.py
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L849-L855
def accel_move_tab_left(self, *args): # TODO KEYBINDINGS ONLY """ Callback to move a tab to the left """ pos = self.get_notebook().get_current_page() if pos != 0: self.move_tab(pos, pos - 1) return True
[ "def", "accel_move_tab_left", "(", "self", ",", "*", "args", ")", ":", "# TODO KEYBINDINGS ONLY", "pos", "=", "self", ".", "get_notebook", "(", ")", ".", "get_current_page", "(", ")", "if", "pos", "!=", "0", ":", "self", ".", "move_tab", "(", "pos", ",",...
Callback to move a tab to the left
[ "Callback", "to", "move", "a", "tab", "to", "the", "left" ]
python
train
35.428571
Dallinger/Dallinger
dallinger/models.py
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/models.py#L232-L247
def infos(self, type=None, failed=False): """Get all infos created by the participants nodes. Return a list of infos produced by nodes associated with the participant. If specified, ``type`` filters by class. By default, failed infos are excluded, to include only failed nodes use ``fail...
[ "def", "infos", "(", "self", ",", "type", "=", "None", ",", "failed", "=", "False", ")", ":", "nodes", "=", "self", ".", "nodes", "(", "failed", "=", "\"all\"", ")", "infos", "=", "[", "]", "for", "n", "in", "nodes", ":", "infos", ".", "extend", ...
Get all infos created by the participants nodes. Return a list of infos produced by nodes associated with the participant. If specified, ``type`` filters by class. By default, failed infos are excluded, to include only failed nodes use ``failed=True``, for all nodes use ``failed=all``. ...
[ "Get", "all", "infos", "created", "by", "the", "participants", "nodes", "." ]
python
train
41.5625
jantman/awslimitchecker
awslimitchecker/services/cloudtrail.py
https://github.com/jantman/awslimitchecker/blob/e50197f70f3d0abcc5cfc7fde6336f548b790e34/awslimitchecker/services/cloudtrail.py#L71-L106
def _find_usage_cloudtrail(self): """Calculate current usage for CloudTrail related metrics""" trail_list = self.conn.describe_trails()['trailList'] trail_count = len(trail_list) if trail_list else 0 for trail in trail_list: data_resource_count = 0 if self.conn....
[ "def", "_find_usage_cloudtrail", "(", "self", ")", ":", "trail_list", "=", "self", ".", "conn", ".", "describe_trails", "(", ")", "[", "'trailList'", "]", "trail_count", "=", "len", "(", "trail_list", ")", "if", "trail_list", "else", "0", "for", "trail", "...
Calculate current usage for CloudTrail related metrics
[ "Calculate", "current", "usage", "for", "CloudTrail", "related", "metrics" ]
python
train
42.583333
estnltk/estnltk
estnltk/vabamorf/morf.py
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/vabamorf/morf.py#L302-L308
def postprocess_result(morphresult, trim_phonetic, trim_compound): """Postprocess vabamorf wrapper output.""" word, analysis = morphresult return { 'text': deconvert(word), 'analysis': [postprocess_analysis(a, trim_phonetic, trim_compound) for a in analysis] }
[ "def", "postprocess_result", "(", "morphresult", ",", "trim_phonetic", ",", "trim_compound", ")", ":", "word", ",", "analysis", "=", "morphresult", "return", "{", "'text'", ":", "deconvert", "(", "word", ")", ",", "'analysis'", ":", "[", "postprocess_analysis", ...
Postprocess vabamorf wrapper output.
[ "Postprocess", "vabamorf", "wrapper", "output", "." ]
python
train
40.857143
quantopian/zipline
zipline/finance/position.py
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/position.py#L91-L129
def handle_split(self, asset, ratio): """ Update the position by the split ratio, and return the resulting fractional share that will be converted into cash. Returns the unused cash. """ if self.asset != asset: raise Exception("updating split with the wrong a...
[ "def", "handle_split", "(", "self", ",", "asset", ",", "ratio", ")", ":", "if", "self", ".", "asset", "!=", "asset", ":", "raise", "Exception", "(", "\"updating split with the wrong asset!\"", ")", "# adjust the # of shares by the ratio", "# (if we had 100 shares, and t...
Update the position by the split ratio, and return the resulting fractional share that will be converted into cash. Returns the unused cash.
[ "Update", "the", "position", "by", "the", "split", "ratio", "and", "return", "the", "resulting", "fractional", "share", "that", "will", "be", "converted", "into", "cash", "." ]
python
train
32.974359
chrisjsewell/jsonextended
jsonextended/edict.py
https://github.com/chrisjsewell/jsonextended/blob/c3a7a880cc09789b3c61204265dcbb127be76c8a/jsonextended/edict.py#L841-L871
def flatten2d(d, key_as_tuple=True, delim='.', list_of_dicts=None): """ get nested dict as {key:dict,...}, where key is tuple/string of all-1 nested keys NB: is same as flattennd(d,1,key_as_tuple,delim) Parameters ---------- d : dict key_as_tuple : bool whether keys a...
[ "def", "flatten2d", "(", "d", ",", "key_as_tuple", "=", "True", ",", "delim", "=", "'.'", ",", "list_of_dicts", "=", "None", ")", ":", "return", "flattennd", "(", "d", ",", "1", ",", "key_as_tuple", ",", "delim", ",", "list_of_dicts", "=", "list_of_dicts...
get nested dict as {key:dict,...}, where key is tuple/string of all-1 nested keys NB: is same as flattennd(d,1,key_as_tuple,delim) Parameters ---------- d : dict key_as_tuple : bool whether keys are list of nested keys or delimited string of nested keys delim : str if key_a...
[ "get", "nested", "dict", "as", "{", "key", ":", "dict", "...", "}", "where", "key", "is", "tuple", "/", "string", "of", "all", "-", "1", "nested", "keys" ]
python
train
29.032258
Opentrons/opentrons
api/src/opentrons/deck_calibration/dc_main.py
https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/deck_calibration/dc_main.py#L267-L286
def save_point(self) -> str: """ Indexes the measured data with the current point as a key and saves the current position once the 'Enter' key is pressed to the 'actual points' vector. """ if self._current_mount is left: msg = self.save_mount_offset() ...
[ "def", "save_point", "(", "self", ")", "->", "str", ":", "if", "self", ".", "_current_mount", "is", "left", ":", "msg", "=", "self", ".", "save_mount_offset", "(", ")", "self", ".", "_current_mount", "=", "right", "elif", "self", ".", "_current_mount", "...
Indexes the measured data with the current point as a key and saves the current position once the 'Enter' key is pressed to the 'actual points' vector.
[ "Indexes", "the", "measured", "data", "with", "the", "current", "point", "as", "a", "key", "and", "saves", "the", "current", "position", "once", "the", "Enter", "key", "is", "pressed", "to", "the", "actual", "points", "vector", "." ]
python
train
41.5
saltstack/salt
salt/modules/vsphere.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vsphere.py#L4800-L4835
def create_storage_policy(policy_name, policy_dict, service_instance=None): ''' Creates a storage policy. Supported capability types: scalar, set, range. policy_name Name of the policy to create. The value of the argument will override any existing name in ``policy_dict``. ...
[ "def", "create_storage_policy", "(", "policy_name", ",", "policy_dict", ",", "service_instance", "=", "None", ")", ":", "log", ".", "trace", "(", "'create storage policy \\'%s\\', dict = %s'", ",", "policy_name", ",", "policy_dict", ")", "profile_manager", "=", "salt"...
Creates a storage policy. Supported capability types: scalar, set, range. policy_name Name of the policy to create. The value of the argument will override any existing name in ``policy_dict``. policy_dict Dictionary containing the changes to apply to the policy. (...
[ "Creates", "a", "storage", "policy", "." ]
python
train
37.805556
woolfson-group/isambard
isambard/external_programs/dssp.py
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/external_programs/dssp.py#L128-L177
def extract_solvent_accessibility_dssp(in_dssp, path=True): """Uses DSSP to extract solvent accessibilty information on every residue. Notes ----- For more information on the solvent accessibility metrics used in dssp, see: http://swift.cmbi.ru.nl/gv/dssp/HTML/descrip.html#ACC In the dssp files...
[ "def", "extract_solvent_accessibility_dssp", "(", "in_dssp", ",", "path", "=", "True", ")", ":", "if", "path", ":", "with", "open", "(", "in_dssp", ",", "'r'", ")", "as", "inf", ":", "dssp_out", "=", "inf", ".", "read", "(", ")", "else", ":", "dssp_out...
Uses DSSP to extract solvent accessibilty information on every residue. Notes ----- For more information on the solvent accessibility metrics used in dssp, see: http://swift.cmbi.ru.nl/gv/dssp/HTML/descrip.html#ACC In the dssp files value is labeled 'ACC'. Parameters ---------- in_dssp...
[ "Uses", "DSSP", "to", "extract", "solvent", "accessibilty", "information", "on", "every", "residue", "." ]
python
train
30.66
leandroarndt/djangospam
djangospam/akismet/moderator.py
https://github.com/leandroarndt/djangospam/blob/57fa9cfbf54a40f0e0652d0155dbb3451c14b69d/djangospam/akismet/moderator.py#L96-L126
def allow(self, comment, content_object, request): """Moderates comments.""" POST = urlencode({ "blog": settings.AKISMET_BLOG.encode("utf-8"), "user_ip": comment.ip_address, "user_agent": request.META.get('HTTP_USER_AGENT', ""). ...
[ "def", "allow", "(", "self", ",", "comment", ",", "content_object", ",", "request", ")", ":", "POST", "=", "urlencode", "(", "{", "\"blog\"", ":", "settings", ".", "AKISMET_BLOG", ".", "encode", "(", "\"utf-8\"", ")", ",", "\"user_ip\"", ":", "comment", ...
Moderates comments.
[ "Moderates", "comments", "." ]
python
train
47.516129
tensorflow/tensor2tensor
tensor2tensor/utils/metrics.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/metrics.py#L435-L451
def sigmoid_accuracy_one_hot(logits, labels, weights_fn=None): """Calculate accuracy for a set, given one-hot labels and logits. Args: logits: Tensor of size [batch-size, o=1, p=1, num-classes] labels: Tensor of size [batch-size, o=1, p=1, num-classes] weights_fn: Function that takes in labels and weig...
[ "def", "sigmoid_accuracy_one_hot", "(", "logits", ",", "labels", ",", "weights_fn", "=", "None", ")", ":", "with", "tf", ".", "variable_scope", "(", "\"sigmoid_accuracy_one_hot\"", ",", "values", "=", "[", "logits", ",", "labels", "]", ")", ":", "del", "weig...
Calculate accuracy for a set, given one-hot labels and logits. Args: logits: Tensor of size [batch-size, o=1, p=1, num-classes] labels: Tensor of size [batch-size, o=1, p=1, num-classes] weights_fn: Function that takes in labels and weighs examples (unused) Returns: accuracy (scalar), weights
[ "Calculate", "accuracy", "for", "a", "set", "given", "one", "-", "hot", "labels", "and", "logits", "." ]
python
train
41.529412
AkihikoITOH/capybara
capybara/virtualenv/lib/python2.7/site-packages/setuptools/msvc9_support.py
https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/setuptools/msvc9_support.py#L8-L25
def patch_for_specialized_compiler(): """ Patch functions in distutils.msvc9compiler to use the standalone compiler build for Python (Windows only). Fall back to original behavior when the standalone compiler is not available. """ if 'distutils' not in globals(): # The module isn't avail...
[ "def", "patch_for_specialized_compiler", "(", ")", ":", "if", "'distutils'", "not", "in", "globals", "(", ")", ":", "# The module isn't available to be patched", "return", "if", "unpatched", ":", "# Already patched", "return", "unpatched", ".", "update", "(", "vars", ...
Patch functions in distutils.msvc9compiler to use the standalone compiler build for Python (Windows only). Fall back to original behavior when the standalone compiler is not available.
[ "Patch", "functions", "in", "distutils", ".", "msvc9compiler", "to", "use", "the", "standalone", "compiler", "build", "for", "Python", "(", "Windows", "only", ")", ".", "Fall", "back", "to", "original", "behavior", "when", "the", "standalone", "compiler", "is"...
python
test
31.777778
prompt-toolkit/pyvim
pyvim/window_arrangement.py
https://github.com/prompt-toolkit/pyvim/blob/5928b53b9d700863c1a06d2181a034a955f94594/pyvim/window_arrangement.py#L272-L281
def close_tab(self): """ Close active tab. """ if len(self.tab_pages) > 1: # Cannot close last tab. del self.tab_pages[self.active_tab_index] self.active_tab_index = max(0, self.active_tab_index - 1) # Clean up buffers. self._auto_close_new_empty...
[ "def", "close_tab", "(", "self", ")", ":", "if", "len", "(", "self", ".", "tab_pages", ")", ">", "1", ":", "# Cannot close last tab.", "del", "self", ".", "tab_pages", "[", "self", ".", "active_tab_index", "]", "self", ".", "active_tab_index", "=", "max", ...
Close active tab.
[ "Close", "active", "tab", "." ]
python
train
32.1
PmagPy/PmagPy
pmagpy/pmag.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L9264-L9271
def s_l(l, alpha): """ get sigma as a function of degree l from Constable and Parker (1988) """ a2 = alpha**2 c_a = 0.547 s_l = np.sqrt(old_div(((c_a**(2. * l)) * a2), ((l + 1.) * (2. * l + 1.)))) return s_l
[ "def", "s_l", "(", "l", ",", "alpha", ")", ":", "a2", "=", "alpha", "**", "2", "c_a", "=", "0.547", "s_l", "=", "np", ".", "sqrt", "(", "old_div", "(", "(", "(", "c_a", "**", "(", "2.", "*", "l", ")", ")", "*", "a2", ")", ",", "(", "(", ...
get sigma as a function of degree l from Constable and Parker (1988)
[ "get", "sigma", "as", "a", "function", "of", "degree", "l", "from", "Constable", "and", "Parker", "(", "1988", ")" ]
python
train
28.5
awkman/pywifi
pywifi/wifi.py
https://github.com/awkman/pywifi/blob/719baf73d8d32c623dbaf5e9de5d973face152a4/pywifi/wifi.py#L36-L50
def interfaces(self): """Collect the available wlan interfaces.""" self._ifaces = [] wifi_ctrl = wifiutil.WifiUtil() for interface in wifi_ctrl.interfaces(): iface = Interface(interface) self._ifaces.append(iface) self._logger.info("Get interface: %s...
[ "def", "interfaces", "(", "self", ")", ":", "self", ".", "_ifaces", "=", "[", "]", "wifi_ctrl", "=", "wifiutil", ".", "WifiUtil", "(", ")", "for", "interface", "in", "wifi_ctrl", ".", "interfaces", "(", ")", ":", "iface", "=", "Interface", "(", "interf...
Collect the available wlan interfaces.
[ "Collect", "the", "available", "wlan", "interfaces", "." ]
python
train
29.333333
Alignak-monitoring/alignak
alignak/objects/hostgroup.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/hostgroup.py#L134-L167
def get_hosts_by_explosion(self, hostgroups): # pylint: disable=access-member-before-definition """ Get hosts of this group :param hostgroups: Hostgroup object :type hostgroups: alignak.objects.hostgroup.Hostgroups :return: list of hosts of this group :rtype: lis...
[ "def", "get_hosts_by_explosion", "(", "self", ",", "hostgroups", ")", ":", "# pylint: disable=access-member-before-definition", "# First we tag the hg so it will not be explode", "# if a son of it already call it", "self", ".", "already_exploded", "=", "True", "# Now the recursive pa...
Get hosts of this group :param hostgroups: Hostgroup object :type hostgroups: alignak.objects.hostgroup.Hostgroups :return: list of hosts of this group :rtype: list
[ "Get", "hosts", "of", "this", "group" ]
python
train
35.352941
theduke/django-baseline
django_baseline/__init__.py
https://github.com/theduke/django-baseline/blob/7be8b956e53c70b35f34e1783a8fe8f716955afb/django_baseline/__init__.py#L43-L52
def user_has_group(user, group, superuser_skip=True): """ Check if a user is in a certaing group. By default, the check is skipped for superusers. """ if user.is_superuser and superuser_skip: return True return user.groups.filter(name=group).exists()
[ "def", "user_has_group", "(", "user", ",", "group", ",", "superuser_skip", "=", "True", ")", ":", "if", "user", ".", "is_superuser", "and", "superuser_skip", ":", "return", "True", "return", "user", ".", "groups", ".", "filter", "(", "name", "=", "group", ...
Check if a user is in a certaing group. By default, the check is skipped for superusers.
[ "Check", "if", "a", "user", "is", "in", "a", "certaing", "group", ".", "By", "default", "the", "check", "is", "skipped", "for", "superusers", "." ]
python
test
27.5
selectel/pyte
pyte/streams.py
https://github.com/selectel/pyte/blob/8adad489f86da1788a7995720c344a2fa44f244e/pyte/streams.py#L146-L164
def attach(self, screen): """Adds a given screen to the listener queue. :param pyte.screens.Screen screen: a screen to attach to. """ if self.listener is not None: warnings.warn("As of version 0.6.0 the listener queue is " "restricted to a single el...
[ "def", "attach", "(", "self", ",", "screen", ")", ":", "if", "self", ".", "listener", "is", "not", "None", ":", "warnings", ".", "warn", "(", "\"As of version 0.6.0 the listener queue is \"", "\"restricted to a single element. Existing \"", "\"listener {0} will be replace...
Adds a given screen to the listener queue. :param pyte.screens.Screen screen: a screen to attach to.
[ "Adds", "a", "given", "screen", "to", "the", "listener", "queue", "." ]
python
train
38.526316
coinkite/connectrum
connectrum/svr_info.py
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/svr_info.py#L171-L178
def from_json(self, fname): ''' Read contents of a CSV containing a list of servers. ''' with open(fname, 'rt') as fp: for row in json.load(fp): nn = ServerInfo.from_dict(row) self[str(nn)] = nn
[ "def", "from_json", "(", "self", ",", "fname", ")", ":", "with", "open", "(", "fname", ",", "'rt'", ")", "as", "fp", ":", "for", "row", "in", "json", ".", "load", "(", "fp", ")", ":", "nn", "=", "ServerInfo", ".", "from_dict", "(", "row", ")", ...
Read contents of a CSV containing a list of servers.
[ "Read", "contents", "of", "a", "CSV", "containing", "a", "list", "of", "servers", "." ]
python
train
33.375
oscarlazoarjona/fast
fast/graphic.py
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/graphic.py#L476-L499
def bar_chart_mf(data, path_name): """Make a bar chart for data on MF quantities.""" N = len(data) ind = np.arange(N) # the x locations for the groups width = 0.8 # the width of the bars fig, ax = pyplot.subplots() rects1 = ax.bar(ind, data, width, color='g') # add some t...
[ "def", "bar_chart_mf", "(", "data", ",", "path_name", ")", ":", "N", "=", "len", "(", "data", ")", "ind", "=", "np", ".", "arange", "(", "N", ")", "# the x locations for the groups\r", "width", "=", "0.8", "# the width of the bars\r", "fig", ",", "ax", "="...
Make a bar chart for data on MF quantities.
[ "Make", "a", "bar", "chart", "for", "data", "on", "MF", "quantities", "." ]
python
train
28.458333
DLR-RM/RAFCON
source/rafcon/gui/controllers/states_editor.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/controllers/states_editor.py#L285-L333
def add_state_editor(self, state_m): """Triggered whenever a state is selected. :param state_m: The selected state model. """ state_identifier = self.get_state_identifier(state_m) if state_identifier in self.closed_tabs: state_editor_ctrl = self.closed_tabs[state_id...
[ "def", "add_state_editor", "(", "self", ",", "state_m", ")", ":", "state_identifier", "=", "self", ".", "get_state_identifier", "(", "state_m", ")", "if", "state_identifier", "in", "self", ".", "closed_tabs", ":", "state_editor_ctrl", "=", "self", ".", "closed_t...
Triggered whenever a state is selected. :param state_m: The selected state model.
[ "Triggered", "whenever", "a", "state", "is", "selected", "." ]
python
train
58.714286
google/grr
grr/core/grr_response_core/lib/rdfvalues/crypto.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/crypto.py#L132-L160
def Verify(self, public_key): """Verifies the certificate using the given key. Args: public_key: The public key to use. Returns: True: Everything went well. Raises: VerificationError: The certificate did not verify. """ # TODO(amoser): We have to do this manually for now sin...
[ "def", "Verify", "(", "self", ",", "public_key", ")", ":", "# TODO(amoser): We have to do this manually for now since cryptography does", "# not yet support cert verification. There is PR 2460:", "# https://github.com/pyca/cryptography/pull/2460/files", "# that will add it, once it's in we sho...
Verifies the certificate using the given key. Args: public_key: The public key to use. Returns: True: Everything went well. Raises: VerificationError: The certificate did not verify.
[ "Verifies", "the", "certificate", "using", "the", "given", "key", "." ]
python
train
33.344828
Bachmann1234/diff-cover
diff_cover/report_generator.py
https://github.com/Bachmann1234/diff-cover/blob/901cb3fc986982961785e841658085ead453c6c9/diff_cover/report_generator.py#L237-L278
def _context(self): """ Return the context to pass to the template. The context is a dict of the form: { 'css_url': CSS_URL, 'report_name': REPORT_NAME, 'diff_name': DIFF_NAME, 'src_stats': {SRC_PATH: { 'percen...
[ "def", "_context", "(", "self", ")", ":", "# Calculate the information to pass to the template", "src_stats", "=", "{", "src", ":", "self", ".", "_src_path_stats", "(", "src", ")", "for", "src", "in", "self", ".", "src_paths", "(", ")", "}", "# Include snippet s...
Return the context to pass to the template. The context is a dict of the form: { 'css_url': CSS_URL, 'report_name': REPORT_NAME, 'diff_name': DIFF_NAME, 'src_stats': {SRC_PATH: { 'percent_covered': PERCENT_COVERED, ...
[ "Return", "the", "context", "to", "pass", "to", "the", "template", "." ]
python
train
33.666667
pybel/pybel
src/pybel/struct/graph.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L573-L575
def get_edge_annotations(self, u, v, key: str) -> Optional[AnnotationsDict]: """Get the annotations for a given edge.""" return self._get_edge_attr(u, v, key, ANNOTATIONS)
[ "def", "get_edge_annotations", "(", "self", ",", "u", ",", "v", ",", "key", ":", "str", ")", "->", "Optional", "[", "AnnotationsDict", "]", ":", "return", "self", ".", "_get_edge_attr", "(", "u", ",", "v", ",", "key", ",", "ANNOTATIONS", ")" ]
Get the annotations for a given edge.
[ "Get", "the", "annotations", "for", "a", "given", "edge", "." ]
python
train
61.666667
bxlab/bx-python
lib/bx/misc/binary_file.py
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/misc/binary_file.py#L145-L150
def write_c_string( self, value ): """ Read a zero terminated (C style) string """ self.file.write( value ) self.file.write( b'\0' )
[ "def", "write_c_string", "(", "self", ",", "value", ")", ":", "self", ".", "file", ".", "write", "(", "value", ")", "self", ".", "file", ".", "write", "(", "b'\\0'", ")" ]
Read a zero terminated (C style) string
[ "Read", "a", "zero", "terminated", "(", "C", "style", ")", "string" ]
python
train
27.833333
tomplus/kubernetes_asyncio
kubernetes_asyncio/client/api/core_v1_api.py
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/core_v1_api.py#L17815-L17836
def read_namespace_status(self, name, **kwargs): # noqa: E501 """read_namespace_status # noqa: E501 read status of the specified Namespace # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>...
[ "def", "read_namespace_status", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", ".", "read...
read_namespace_status # noqa: E501 read status of the specified Namespace # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.read_namespace_status(name, async_req=True) >>> res...
[ "read_namespace_status", "#", "noqa", ":", "E501" ]
python
train
45.545455
jim-easterbrook/Photini
src/photini/metadata.py
https://github.com/jim-easterbrook/Photini/blob/06f1b1988db23a5cad98bbc6c16406a64a6c556d/src/photini/metadata.py#L412-L436
def from_ISO_8601(cls, date_string, time_string, tz_string): """Sufficiently general ISO 8601 parser. Inputs must be in "basic" format, i.e. no '-' or ':' separators. See https://en.wikipedia.org/wiki/ISO_8601 """ # parse tz_string if tz_string: tz_offset = ...
[ "def", "from_ISO_8601", "(", "cls", ",", "date_string", ",", "time_string", ",", "tz_string", ")", ":", "# parse tz_string", "if", "tz_string", ":", "tz_offset", "=", "(", "int", "(", "tz_string", "[", "1", ":", "3", "]", ")", "*", "60", ")", "+", "int...
Sufficiently general ISO 8601 parser. Inputs must be in "basic" format, i.e. no '-' or ':' separators. See https://en.wikipedia.org/wiki/ISO_8601
[ "Sufficiently", "general", "ISO", "8601", "parser", "." ]
python
train
37.6
fracpete/python-weka-wrapper3
python/weka/core/classes.py
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L2001-L2011
def parameters(self, params): """ Sets the list of search parameters to use. :param params: list of AbstractSearchParameter objects :type params: list """ array = JavaArray(jobject=JavaArray.new_instance("weka.core.setupgenerator.AbstractParameter", len(params))) ...
[ "def", "parameters", "(", "self", ",", "params", ")", ":", "array", "=", "JavaArray", "(", "jobject", "=", "JavaArray", ".", "new_instance", "(", "\"weka.core.setupgenerator.AbstractParameter\"", ",", "len", "(", "params", ")", ")", ")", "for", "idx", ",", "...
Sets the list of search parameters to use. :param params: list of AbstractSearchParameter objects :type params: list
[ "Sets", "the", "list", "of", "search", "parameters", "to", "use", "." ]
python
train
45.818182
tanghaibao/jcvi
jcvi/assembly/hic.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/assembly/hic.py#L429-L444
def O(self): """ Pairwise strandedness matrix. Each cell contains whether i-th and j-th contig are the same orientation +1, or opposite orientation -1. """ N = self.N tig_to_idx = self.tig_to_idx O = np.zeros((N, N), dtype=int) for (at, bt), (strandedness,...
[ "def", "O", "(", "self", ")", ":", "N", "=", "self", ".", "N", "tig_to_idx", "=", "self", ".", "tig_to_idx", "O", "=", "np", ".", "zeros", "(", "(", "N", ",", "N", ")", ",", "dtype", "=", "int", ")", "for", "(", "at", ",", "bt", ")", ",", ...
Pairwise strandedness matrix. Each cell contains whether i-th and j-th contig are the same orientation +1, or opposite orientation -1.
[ "Pairwise", "strandedness", "matrix", ".", "Each", "cell", "contains", "whether", "i", "-", "th", "and", "j", "-", "th", "contig", "are", "the", "same", "orientation", "+", "1", "or", "opposite", "orientation", "-", "1", "." ]
python
train
36.8125
pallets/werkzeug
src/werkzeug/routing.py
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/routing.py#L1555-L1565
def add(self, rulefactory): """Add a new rule or factory to the map and bind it. Requires that the rule is not bound to another map. :param rulefactory: a :class:`Rule` or :class:`RuleFactory` """ for rule in rulefactory.get_rules(self): rule.bind(self) ...
[ "def", "add", "(", "self", ",", "rulefactory", ")", ":", "for", "rule", "in", "rulefactory", ".", "get_rules", "(", "self", ")", ":", "rule", ".", "bind", "(", "self", ")", "self", ".", "_rules", ".", "append", "(", "rule", ")", "self", ".", "_rule...
Add a new rule or factory to the map and bind it. Requires that the rule is not bound to another map. :param rulefactory: a :class:`Rule` or :class:`RuleFactory`
[ "Add", "a", "new", "rule", "or", "factory", "to", "the", "map", "and", "bind", "it", ".", "Requires", "that", "the", "rule", "is", "not", "bound", "to", "another", "map", "." ]
python
train
40
matthieugouel/gibica
gibica/parser.py
https://github.com/matthieugouel/gibica/blob/65f937f7a6255078cc22eb7691a2897466032909/gibica/parser.py#L258-L290
def comparison(self): """ comparison: expr (('==' | '!=' | '<=' | '>=' | '<' | '>') expr)* """ node = self.expr() while self.token.nature in ( Nature.EQ, Nature.NE, Nature.LE, Nature.GE, Nature.LT, Nature.GT...
[ "def", "comparison", "(", "self", ")", ":", "node", "=", "self", ".", "expr", "(", ")", "while", "self", ".", "token", ".", "nature", "in", "(", "Nature", ".", "EQ", ",", "Nature", ".", "NE", ",", "Nature", ".", "LE", ",", "Nature", ".", "GE", ...
comparison: expr (('==' | '!=' | '<=' | '>=' | '<' | '>') expr)*
[ "comparison", ":", "expr", "((", "==", "|", "!", "=", "|", "<", "=", "|", ">", "=", "|", "<", "|", ">", ")", "expr", ")", "*" ]
python
train
29.787879
PGower/PyCanvas
pycanvas/apis/quiz_reports.py
https://github.com/PGower/PyCanvas/blob/68520005382b440a1e462f9df369f54d364e21e8/pycanvas/apis/quiz_reports.py#L46-L91
def create_quiz_report(self, quiz_id, course_id, quiz_report_report_type, include=None, quiz_report_includes_all_versions=None): """ Create a quiz report. Create and return a new report for this quiz. If a previously generated report matches the arguments and is still current (i.e....
[ "def", "create_quiz_report", "(", "self", ",", "quiz_id", ",", "course_id", ",", "quiz_report_report_type", ",", "include", "=", "None", ",", "quiz_report_includes_all_versions", "=", "None", ")", ":", "path", "=", "{", "}", "data", "=", "{", "}", "params", ...
Create a quiz report. Create and return a new report for this quiz. If a previously generated report matches the arguments and is still current (i.e. there have been no new submissions), it will be returned. *Responses* * <code>400 Bad Request</code> if...
[ "Create", "a", "quiz", "report", ".", "Create", "and", "return", "a", "new", "report", "for", "this", "quiz", ".", "If", "a", "previously", "generated", "report", "matches", "the", "arguments", "and", "is", "still", "current", "(", "i", ".", "e", ".", ...
python
train
46.152174
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/authproxy.py
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/authproxy.py#L203-L251
def getinfo(self): """ Backwards-compatibility for 0.14 and later """ try: old_getinfo = AuthServiceProxy(self.__service_url, 'getinfo', self.__timeout, self.__conn, True) res = old_getinfo() if 'error' not in res: # 0.13 and earlier ...
[ "def", "getinfo", "(", "self", ")", ":", "try", ":", "old_getinfo", "=", "AuthServiceProxy", "(", "self", ".", "__service_url", ",", "'getinfo'", ",", "self", ".", "__timeout", ",", "self", ".", "__conn", ",", "True", ")", "res", "=", "old_getinfo", "(",...
Backwards-compatibility for 0.14 and later
[ "Backwards", "-", "compatibility", "for", "0", ".", "14", "and", "later" ]
python
train
34.571429
StanfordVL/robosuite
robosuite/models/objects/generated_objects.py
https://github.com/StanfordVL/robosuite/blob/65cd16810e2ed647e3ec88746af3412065b7f278/robosuite/models/objects/generated_objects.py#L309-L325
def _get_randomized_range(val, provided_range, default_range): """ Helper to initialize by either value or a range Returns a range to randomize from """ if val is None: if provided_range is None: return default_range ...
[ "def", "_get_randomized_range", "(", "val", ",", "provided_range", ",", "default_range", ")", ":", "if", "val", "is", "None", ":", "if", "provided_range", "is", "None", ":", "return", "default_range", "else", ":", "return", "provided_range", "else", ":", "if",...
Helper to initialize by either value or a range Returns a range to randomize from
[ "Helper", "to", "initialize", "by", "either", "value", "or", "a", "range", "Returns", "a", "range", "to", "randomize", "from" ]
python
train
32.117647
GoogleCloudPlatform/appengine-gcs-client
python/src/cloudstorage/storage_api.py
https://github.com/GoogleCloudPlatform/appengine-gcs-client/blob/d11078331ecd915d753c886e96a80133599f3f98/python/src/cloudstorage/storage_api.py#L639-L650
def find_newline(self, size=-1): """Search for newline char in buffer starting from current offset. Args: size: number of bytes to search. -1 means all. Returns: offset of newline char in buffer. -1 if doesn't exist. """ if size < 0: return self._buffer.find('\n', self._offset) ...
[ "def", "find_newline", "(", "self", ",", "size", "=", "-", "1", ")", ":", "if", "size", "<", "0", ":", "return", "self", ".", "_buffer", ".", "find", "(", "'\\n'", ",", "self", ".", "_offset", ")", "return", "self", ".", "_buffer", ".", "find", "...
Search for newline char in buffer starting from current offset. Args: size: number of bytes to search. -1 means all. Returns: offset of newline char in buffer. -1 if doesn't exist.
[ "Search", "for", "newline", "char", "in", "buffer", "starting", "from", "current", "offset", "." ]
python
train
31.416667
albertyw/pyziptax
pyziptax/ziptax.py
https://github.com/albertyw/pyziptax/blob/c56dd440e4cadff7f2dd4b72e5dcced06a44969d/pyziptax/ziptax.py#L24-L34
def get_rate(self, zipcode, city=None, state=None, multiple_rates=False): """ Finds sales tax for given info. Returns Decimal of the tax rate, e.g. 8.750. """ data = self.make_request_data(zipcode, city, state) r = requests.get(self.url, params=data) resp = r.jso...
[ "def", "get_rate", "(", "self", ",", "zipcode", ",", "city", "=", "None", ",", "state", "=", "None", ",", "multiple_rates", "=", "False", ")", ":", "data", "=", "self", ".", "make_request_data", "(", "zipcode", ",", "city", ",", "state", ")", "r", "=...
Finds sales tax for given info. Returns Decimal of the tax rate, e.g. 8.750.
[ "Finds", "sales", "tax", "for", "given", "info", ".", "Returns", "Decimal", "of", "the", "tax", "rate", "e", ".", "g", ".", "8", ".", "750", "." ]
python
valid
33.909091
djgagne/hagelslag
hagelslag/data/ModelGrid.py
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/data/ModelGrid.py#L55-L94
def load_data_old(self): """ Loads time series of 2D data grids from each opened file. The code handles loading a full time series from one file or individual time steps from multiple files. Missing files are supported. """ units = "" if len(self.file_objects) ==...
[ "def", "load_data_old", "(", "self", ")", ":", "units", "=", "\"\"", "if", "len", "(", "self", ".", "file_objects", ")", "==", "1", "and", "self", ".", "file_objects", "[", "0", "]", "is", "not", "None", ":", "data", "=", "self", ".", "file_objects",...
Loads time series of 2D data grids from each opened file. The code handles loading a full time series from one file or individual time steps from multiple files. Missing files are supported.
[ "Loads", "time", "series", "of", "2D", "data", "grids", "from", "each", "opened", "file", ".", "The", "code", "handles", "loading", "a", "full", "time", "series", "from", "one", "file", "or", "individual", "time", "steps", "from", "multiple", "files", ".",...
python
train
53.225
tanghaibao/jcvi
jcvi/formats/gff.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/formats/gff.py#L376-L390
def to_range(obj, score=None, id=None, strand=None): """ Given a gffutils object, convert it to a range object """ from jcvi.utils.range import Range if score or id: _score = score if score else obj.score _id = id if id else obj.id return Range(seqid=obj.seqid, start=obj.sta...
[ "def", "to_range", "(", "obj", ",", "score", "=", "None", ",", "id", "=", "None", ",", "strand", "=", "None", ")", ":", "from", "jcvi", ".", "utils", ".", "range", "import", "Range", "if", "score", "or", "id", ":", "_score", "=", "score", "if", "...
Given a gffutils object, convert it to a range object
[ "Given", "a", "gffutils", "object", "convert", "it", "to", "a", "range", "object" ]
python
train
31.866667
bkabrda/anymarkup-core
anymarkup_core/__init__.py
https://github.com/bkabrda/anymarkup-core/blob/299935092fc2650cca4e32ec92441786918f9bab/anymarkup_core/__init__.py#L76-L117
def parse(inp, format=None, encoding='utf-8', force_types=True): """Parse input from file-like object, unicode string or byte string. Args: inp: file-like object, unicode string or byte string with the markup format: explicitly override the guessed `inp` markup format encoding: `inp` en...
[ "def", "parse", "(", "inp", ",", "format", "=", "None", ",", "encoding", "=", "'utf-8'", ",", "force_types", "=", "True", ")", ":", "proper_inp", "=", "inp", "if", "hasattr", "(", "inp", ",", "'read'", ")", ":", "proper_inp", "=", "inp", ".", "read",...
Parse input from file-like object, unicode string or byte string. Args: inp: file-like object, unicode string or byte string with the markup format: explicitly override the guessed `inp` markup format encoding: `inp` encoding, defaults to utf-8 force_types: if `True`, in...
[ "Parse", "input", "from", "file", "-", "like", "object", "unicode", "string", "or", "byte", "string", "." ]
python
train
35.690476
jaredLunde/redis_structures
redis_structures/debug/__init__.py
https://github.com/jaredLunde/redis_structures/blob/b9cce5f5c85db5e12c292633ff8d04e3ae053294/redis_structures/debug/__init__.py#L950-L961
def list(self, size=1000, tree_depth=1): """ Creates a random #list @size: #int number of random values to include in each @tree_depth @tree_depth: #int dict tree dimensions size, i.e. 1=|[value1, value2]| 2=|[[value1, value2], [value1, value2]]| ...
[ "def", "list", "(", "self", ",", "size", "=", "1000", ",", "tree_depth", "=", "1", ")", ":", "if", "not", "tree_depth", ":", "return", "self", ".", "_map_type", "(", ")", "return", "list", "(", "self", ".", "deque", "(", "size", ",", "tree_depth", ...
Creates a random #list @size: #int number of random values to include in each @tree_depth @tree_depth: #int dict tree dimensions size, i.e. 1=|[value1, value2]| 2=|[[value1, value2], [value1, value2]]| -> random #list
[ "Creates", "a", "random", "#list" ]
python
train
38.75
ml4ai/delphi
delphi/translators/for2py/pyTranslate.py
https://github.com/ml4ai/delphi/blob/6d03d8aafeab99610387c51b89c99738ff2abbe3/delphi/translators/for2py/pyTranslate.py#L1151-L1199
def printArray(self, node, printState: PrintState): """ Prints out the array declaration in a format of Array class object declaration. 'arrayName = Array(Type, [bounds])' """ if ( self.nameMapper[node["name"]] not in printState.definedVars and self.nameMapper...
[ "def", "printArray", "(", "self", ",", "node", ",", "printState", ":", "PrintState", ")", ":", "if", "(", "self", ".", "nameMapper", "[", "node", "[", "\"name\"", "]", "]", "not", "in", "printState", ".", "definedVars", "and", "self", ".", "nameMapper", ...
Prints out the array declaration in a format of Array class object declaration. 'arrayName = Array(Type, [bounds])'
[ "Prints", "out", "the", "array", "declaration", "in", "a", "format", "of", "Array", "class", "object", "declaration", ".", "arrayName", "=", "Array", "(", "Type", "[", "bounds", "]", ")" ]
python
train
42.163265
deshima-dev/decode
decode/core/array/functions.py
https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/core/array/functions.py#L124-L141
def zeros_like(array, dtype=None, keepmeta=True): """Create an array of zeros with the same shape and type as the input array. Args: array (xarray.DataArray): The shape and data-type of it define these same attributes of the output array. dtype (data-type, optional): If specified, t...
[ "def", "zeros_like", "(", "array", ",", "dtype", "=", "None", ",", "keepmeta", "=", "True", ")", ":", "if", "keepmeta", ":", "return", "xr", ".", "zeros_like", "(", "array", ",", "dtype", ")", "else", ":", "return", "dc", ".", "zeros", "(", "array", ...
Create an array of zeros with the same shape and type as the input array. Args: array (xarray.DataArray): The shape and data-type of it define these same attributes of the output array. dtype (data-type, optional): If specified, this function overrides the data-type of the o...
[ "Create", "an", "array", "of", "zeros", "with", "the", "same", "shape", "and", "type", "as", "the", "input", "array", "." ]
python
train
39.666667
edx/edx-enterprise
enterprise/api/v1/serializers.py
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L382-L401
def to_representation(self, instance): """ Return the updated course data dictionary. Arguments: instance (dict): The course data. Returns: dict: The updated course data. """ updated_course = copy.deepcopy(instance) enterprise_customer_ca...
[ "def", "to_representation", "(", "self", ",", "instance", ")", ":", "updated_course", "=", "copy", ".", "deepcopy", "(", "instance", ")", "enterprise_customer_catalog", "=", "self", ".", "context", "[", "'enterprise_customer_catalog'", "]", "updated_course", "[", ...
Return the updated course data dictionary. Arguments: instance (dict): The course data. Returns: dict: The updated course data.
[ "Return", "the", "updated", "course", "data", "dictionary", "." ]
python
valid
36.55
pyrogram/pyrogram
pyrogram/client/methods/password/change_cloud_password.py
https://github.com/pyrogram/pyrogram/blob/e7258a341ba905cfa86264c22040654db732ec1c/pyrogram/client/methods/password/change_cloud_password.py#L27-L72
def change_cloud_password( self, current_password: str, new_password: str, new_hint: str = "" ) -> bool: """Use this method to change your Two-Step Verification password (Cloud Password) with a new one. Args: current_password (``str``): Yo...
[ "def", "change_cloud_password", "(", "self", ",", "current_password", ":", "str", ",", "new_password", ":", "str", ",", "new_hint", ":", "str", "=", "\"\"", ")", "->", "bool", ":", "r", "=", "self", ".", "send", "(", "functions", ".", "account", ".", "...
Use this method to change your Two-Step Verification password (Cloud Password) with a new one. Args: current_password (``str``): Your current password. new_password (``str``): Your new password. new_hint (``str``, *optional*): ...
[ "Use", "this", "method", "to", "change", "your", "Two", "-", "Step", "Verification", "password", "(", "Cloud", "Password", ")", "with", "a", "new", "one", "." ]
python
train
30.543478
codeforamerica/epa_python
epa/pcs/pcs.py
https://github.com/codeforamerica/epa_python/blob/62a53da62936bea8daa487a01a52b973e9062b2c/epa/pcs/pcs.py#L173-L182
def sludge(self, column=None, value=None, **kwargs): """ Sludge information describes the volumn of sludge produced at a facility, identification information on a sludge handler, and classification/permitting information on a facility that handles sludge, such as a pretreatment P...
[ "def", "sludge", "(", "self", ",", "column", "=", "None", ",", "value", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_resolve_call", "(", "'PCS_SLUDGE'", ",", "column", ",", "value", ",", "*", "*", "kwargs", ")" ]
Sludge information describes the volumn of sludge produced at a facility, identification information on a sludge handler, and classification/permitting information on a facility that handles sludge, such as a pretreatment POTW. >>> PCS().sludge('county_name', 'San Francisco')
[ "Sludge", "information", "describes", "the", "volumn", "of", "sludge", "produced", "at", "a", "facility", "identification", "information", "on", "a", "sludge", "handler", "and", "classification", "/", "permitting", "information", "on", "a", "facility", "that", "ha...
python
train
45.8
casastorta/python-sar
sar/multiparser.py
https://github.com/casastorta/python-sar/blob/e6d8bb86524102d677f37e985302fad34e3297c1/sar/multiparser.py#L132-L180
def __split_file(self): ''' Splits combined SAR output file (in ASCII format) in order to extract info we need for it, in the format we want. :return: ``List``-style of SAR file sections separated by the type of info they contain (SAR file sections) without ...
[ "def", "__split_file", "(", "self", ")", ":", "# Filename passed checks through __init__", "if", "(", "self", ".", "__filename", "and", "os", ".", "access", "(", "self", ".", "__filename", ",", "os", ".", "R_OK", ")", ")", ":", "fhandle", "=", "None", "try...
Splits combined SAR output file (in ASCII format) in order to extract info we need for it, in the format we want. :return: ``List``-style of SAR file sections separated by the type of info they contain (SAR file sections) without parsing what is exactly what at this p...
[ "Splits", "combined", "SAR", "output", "file", "(", "in", "ASCII", "format", ")", "in", "order", "to", "extract", "info", "we", "need", "for", "it", "in", "the", "format", "we", "want", ".", ":", "return", ":", "List", "-", "style", "of", "SAR", "fil...
python
train
33.591837
thombashi/typepy
typepy/converter/_datetime.py
https://github.com/thombashi/typepy/blob/8209d1df4f2a7f196a9fa4bfb0708c5ff648461f/typepy/converter/_datetime.py#L131-L147
def __validate_datetime_string(self): """ This will require validating version string (such as "3.3.5"). A version string could be converted to a datetime value if this validation is not executed. """ try: try: StrictVersion(self._value) ...
[ "def", "__validate_datetime_string", "(", "self", ")", ":", "try", ":", "try", ":", "StrictVersion", "(", "self", ".", "_value", ")", "raise", "TypeConversionError", "(", "\"invalid datetime string: version string found {}\"", ".", "format", "(", "self", ".", "_valu...
This will require validating version string (such as "3.3.5"). A version string could be converted to a datetime value if this validation is not executed.
[ "This", "will", "require", "validating", "version", "string", "(", "such", "as", "3", ".", "3", ".", "5", ")", ".", "A", "version", "string", "could", "be", "converted", "to", "a", "datetime", "value", "if", "this", "validation", "is", "not", "executed",...
python
train
36.941176