Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
CastDevice.media_album_artist | (self) | Album artist of current playing media (Music track only). | Album artist of current playing media (Music track only). | def media_album_artist(self):
"""Album artist of current playing media (Music track only)."""
media_status, _ = self._media_status()
return media_status.album_artist if media_status else None | [
"def",
"media_album_artist",
"(",
"self",
")",
":",
"media_status",
",",
"_",
"=",
"self",
".",
"_media_status",
"(",
")",
"return",
"media_status",
".",
"album_artist",
"if",
"media_status",
"else",
"None"
] | [
695,
4
] | [
698,
66
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.media_track | (self) | Track number of current playing media (Music track only). | Track number of current playing media (Music track only). | def media_track(self):
"""Track number of current playing media (Music track only)."""
media_status, _ = self._media_status()
return media_status.track if media_status else None | [
"def",
"media_track",
"(",
"self",
")",
":",
"media_status",
",",
"_",
"=",
"self",
".",
"_media_status",
"(",
")",
"return",
"media_status",
".",
"track",
"if",
"media_status",
"else",
"None"
] | [
701,
4
] | [
704,
59
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.media_series_title | (self) | Return the title of the series of current playing media. | Return the title of the series of current playing media. | def media_series_title(self):
"""Return the title of the series of current playing media."""
media_status, _ = self._media_status()
return media_status.series_title if media_status else None | [
"def",
"media_series_title",
"(",
"self",
")",
":",
"media_status",
",",
"_",
"=",
"self",
".",
"_media_status",
"(",
")",
"return",
"media_status",
".",
"series_title",
"if",
"media_status",
"else",
"None"
] | [
707,
4
] | [
710,
66
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.media_season | (self) | Season of current playing media (TV Show only). | Season of current playing media (TV Show only). | def media_season(self):
"""Season of current playing media (TV Show only)."""
media_status, _ = self._media_status()
return media_status.season if media_status else None | [
"def",
"media_season",
"(",
"self",
")",
":",
"media_status",
",",
"_",
"=",
"self",
".",
"_media_status",
"(",
")",
"return",
"media_status",
".",
"season",
"if",
"media_status",
"else",
"None"
] | [
713,
4
] | [
716,
60
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.media_episode | (self) | Episode of current playing media (TV Show only). | Episode of current playing media (TV Show only). | def media_episode(self):
"""Episode of current playing media (TV Show only)."""
media_status, _ = self._media_status()
return media_status.episode if media_status else None | [
"def",
"media_episode",
"(",
"self",
")",
":",
"media_status",
",",
"_",
"=",
"self",
".",
"_media_status",
"(",
")",
"return",
"media_status",
".",
"episode",
"if",
"media_status",
"else",
"None"
] | [
719,
4
] | [
722,
61
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.app_id | (self) | Return the ID of the current running app. | Return the ID of the current running app. | def app_id(self):
"""Return the ID of the current running app."""
return self._chromecast.app_id if self._chromecast else None | [
"def",
"app_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_chromecast",
".",
"app_id",
"if",
"self",
".",
"_chromecast",
"else",
"None"
] | [
725,
4
] | [
727,
68
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.app_name | (self) | Name of the current running app. | Name of the current running app. | def app_name(self):
"""Name of the current running app."""
return self._chromecast.app_display_name if self._chromecast else None | [
"def",
"app_name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_chromecast",
".",
"app_display_name",
"if",
"self",
".",
"_chromecast",
"else",
"None"
] | [
730,
4
] | [
732,
78
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.supported_features | (self) | Flag media player features that are supported. | Flag media player features that are supported. | def supported_features(self):
"""Flag media player features that are supported."""
support = SUPPORT_CAST
media_status, _ = self._media_status()
if media_status:
if media_status.supports_queue_next:
support |= SUPPORT_PREVIOUS_TRACK
if media_statu... | [
"def",
"supported_features",
"(",
"self",
")",
":",
"support",
"=",
"SUPPORT_CAST",
"media_status",
",",
"_",
"=",
"self",
".",
"_media_status",
"(",
")",
"if",
"media_status",
":",
"if",
"media_status",
".",
"supports_queue_next",
":",
"support",
"|=",
"SUPPO... | [
735,
4
] | [
751,
22
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.media_position | (self) | Position of current playing media in seconds. | Position of current playing media in seconds. | def media_position(self):
"""Position of current playing media in seconds."""
media_status, _ = self._media_status()
if media_status is None or not (
media_status.player_is_playing
or media_status.player_is_paused
or media_status.player_is_idle
):
... | [
"def",
"media_position",
"(",
"self",
")",
":",
"media_status",
",",
"_",
"=",
"self",
".",
"_media_status",
"(",
")",
"if",
"media_status",
"is",
"None",
"or",
"not",
"(",
"media_status",
".",
"player_is_playing",
"or",
"media_status",
".",
"player_is_paused"... | [
754,
4
] | [
763,
40
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.media_position_updated_at | (self) | When was the position of the current playing media valid.
Returns value from homeassistant.util.dt.utcnow().
| When was the position of the current playing media valid. | def media_position_updated_at(self):
"""When was the position of the current playing media valid.
Returns value from homeassistant.util.dt.utcnow().
"""
_, media_status_recevied = self._media_status()
return media_status_recevied | [
"def",
"media_position_updated_at",
"(",
"self",
")",
":",
"_",
",",
"media_status_recevied",
"=",
"self",
".",
"_media_status",
"(",
")",
"return",
"media_status_recevied"
] | [
766,
4
] | [
772,
36
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> Optional[str]:
"""Return a unique ID."""
return self._cast_info.uuid | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_cast_info",
".",
"uuid"
] | [
775,
4
] | [
777,
35
] | python | ca | ['fr', 'ca', 'en'] | False |
CastDevice._async_cast_discovered | (self, discover: ChromecastInfo) | Handle discovery of new Chromecast. | Handle discovery of new Chromecast. | async def _async_cast_discovered(self, discover: ChromecastInfo):
"""Handle discovery of new Chromecast."""
if self._cast_info.uuid is None:
# We can't handle empty UUIDs
return
if self._cast_info.uuid != discover.uuid:
# Discovered is not our device.
... | [
"async",
"def",
"_async_cast_discovered",
"(",
"self",
",",
"discover",
":",
"ChromecastInfo",
")",
":",
"if",
"self",
".",
"_cast_info",
".",
"uuid",
"is",
"None",
":",
"# We can't handle empty UUIDs",
"return",
"if",
"self",
".",
"_cast_info",
".",
"uuid",
"... | [
779,
4
] | [
790,
48
] | python | en | ['en', 'en', 'en'] | True |
CastDevice._async_stop | (self, event) | Disconnect socket on Home Assistant stop. | Disconnect socket on Home Assistant stop. | async def _async_stop(self, event):
"""Disconnect socket on Home Assistant stop."""
await self._async_disconnect() | [
"async",
"def",
"_async_stop",
"(",
"self",
",",
"event",
")",
":",
"await",
"self",
".",
"_async_disconnect",
"(",
")"
] | [
792,
4
] | [
794,
38
] | python | en | ['en', 'en', 'en'] | True |
CastDevice._handle_signal_show_view | (
self,
controller: HomeAssistantController,
entity_id: str,
view_path: str,
url_path: Optional[str],
) | Handle a show view signal. | Handle a show view signal. | def _handle_signal_show_view(
self,
controller: HomeAssistantController,
entity_id: str,
view_path: str,
url_path: Optional[str],
):
"""Handle a show view signal."""
if entity_id != self.entity_id:
return
if self._hass_cast_controller is N... | [
"def",
"_handle_signal_show_view",
"(",
"self",
",",
"controller",
":",
"HomeAssistantController",
",",
"entity_id",
":",
"str",
",",
"view_path",
":",
"str",
",",
"url_path",
":",
"Optional",
"[",
"str",
"]",
",",
")",
":",
"if",
"entity_id",
"!=",
"self",
... | [
796,
4
] | [
811,
74
] | python | en | ['en', 'en', 'en'] | True |
train | (args, train_dataset, model, tokenizer, teacher=None) | Train the model | Train the model | def train(args, train_dataset, model, tokenizer, teacher=None):
""" Train the model """
if args.local_rank in [-1, 0]:
tb_writer = SummaryWriter(log_dir=args.output_dir)
args.train_batch_size = args.per_gpu_train_batch_size * max(1, args.n_gpu)
train_sampler = RandomSampler(train_dataset) if ar... | [
"def",
"train",
"(",
"args",
",",
"train_dataset",
",",
"model",
",",
"tokenizer",
",",
"teacher",
"=",
"None",
")",
":",
"if",
"args",
".",
"local_rank",
"in",
"[",
"-",
"1",
",",
"0",
"]",
":",
"tb_writer",
"=",
"SummaryWriter",
"(",
"log_dir",
"="... | [
114,
0
] | [
441,
45
] | python | en | ['en', 'it', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up a Xiaomi Camera. | Set up a Xiaomi Camera. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up a Xiaomi Camera."""
_LOGGER.debug("Received configuration for model %s", config[CONF_MODEL])
async_add_entities([XiaomiCamera(hass, config)]) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Received configuration for model %s\"",
",",
"config",
"[",
"CONF_MODEL",
"]",
")",
"async... | [
51,
0
] | [
54,
52
] | python | en | ['en', 'ca', 'en'] | True |
XiaomiCamera.__init__ | (self, hass, config) | Initialize. | Initialize. | def __init__(self, hass, config):
"""Initialize."""
super().__init__()
self._extra_arguments = config.get(CONF_FFMPEG_ARGUMENTS)
self._last_image = None
self._last_url = None
self._manager = hass.data[DATA_FFMPEG]
self._name = config[CONF_NAME]
self.host =... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"config",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_extra_arguments",
"=",
"config",
".",
"get",
"(",
"CONF_FFMPEG_ARGUMENTS",
")",
"self",
".",
"_last_image",
"=",
"None",
... | [
60,
4
] | [
74,
43
] | python | en | ['en', 'en', 'it'] | False |
XiaomiCamera.name | (self) | Return the name of this camera. | Return the name of this camera. | def name(self):
"""Return the name of this camera."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
77,
4
] | [
79,
25
] | python | en | ['en', 'en', 'en'] | True |
XiaomiCamera.brand | (self) | Return the camera brand. | Return the camera brand. | def brand(self):
"""Return the camera brand."""
return DEFAULT_BRAND | [
"def",
"brand",
"(",
"self",
")",
":",
"return",
"DEFAULT_BRAND"
] | [
82,
4
] | [
84,
28
] | python | en | ['en', 'bs', 'en'] | True |
XiaomiCamera.model | (self) | Return the camera model. | Return the camera model. | def model(self):
"""Return the camera model."""
return self._model | [
"def",
"model",
"(",
"self",
")",
":",
"return",
"self",
".",
"_model"
] | [
87,
4
] | [
89,
26
] | python | en | ['en', 'co', 'en'] | True |
XiaomiCamera.get_latest_video_url | (self, host) | Retrieve the latest video file from the Xiaomi Camera FTP server. | Retrieve the latest video file from the Xiaomi Camera FTP server. | def get_latest_video_url(self, host):
"""Retrieve the latest video file from the Xiaomi Camera FTP server."""
ftp = FTP(host)
try:
ftp.login(self.user, self.passwd)
except error_perm as exc:
_LOGGER.error("Camera login failed: %s", exc)
return False
... | [
"def",
"get_latest_video_url",
"(",
"self",
",",
"host",
")",
":",
"ftp",
"=",
"FTP",
"(",
"host",
")",
"try",
":",
"ftp",
".",
"login",
"(",
"self",
".",
"user",
",",
"self",
".",
"passwd",
")",
"except",
"error_perm",
"as",
"exc",
":",
"_LOGGER",
... | [
91,
4
] | [
138,
87
] | python | en | ['en', 'en', 'en'] | True |
XiaomiCamera.async_camera_image | (self) | Return a still image response from the camera. | Return a still image response from the camera. | async def async_camera_image(self):
"""Return a still image response from the camera."""
try:
host = self.host.async_render(parse_result=False)
except TemplateError as exc:
_LOGGER.error("Error parsing template %s: %s", self.host, exc)
return self._last_image... | [
"async",
"def",
"async_camera_image",
"(",
"self",
")",
":",
"try",
":",
"host",
"=",
"self",
".",
"host",
".",
"async_render",
"(",
"parse_result",
"=",
"False",
")",
"except",
"TemplateError",
"as",
"exc",
":",
"_LOGGER",
".",
"error",
"(",
"\"Error pars... | [
140,
4
] | [
159,
31
] | python | en | ['en', 'en', 'en'] | True |
XiaomiCamera.handle_async_mjpeg_stream | (self, request) | Generate an HTTP MJPEG stream from the camera. | Generate an HTTP MJPEG stream from the camera. | async def handle_async_mjpeg_stream(self, request):
"""Generate an HTTP MJPEG stream from the camera."""
stream = CameraMjpeg(self._manager.binary, loop=self.hass.loop)
await stream.open_camera(self._last_url, extra_cmd=self._extra_arguments)
try:
stream_reader = await stre... | [
"async",
"def",
"handle_async_mjpeg_stream",
"(",
"self",
",",
"request",
")",
":",
"stream",
"=",
"CameraMjpeg",
"(",
"self",
".",
"_manager",
".",
"binary",
",",
"loop",
"=",
"self",
".",
"hass",
".",
"loop",
")",
"await",
"stream",
".",
"open_camera",
... | [
161,
4
] | [
176,
32
] | python | en | ['en', 'en', 'en'] | True |
FlaxBertLayerNorm.__call__ | (self, x) |
Applies layer normalization on the input. It normalizes the activations of the layer for each given example in
a batch independently, rather than across a batch like Batch Normalization. i.e. applies a transformation that
maintains the mean activation within each example close to 0 and the acti... |
Applies layer normalization on the input. It normalizes the activations of the layer for each given example in
a batch independently, rather than across a batch like Batch Normalization. i.e. applies a transformation that
maintains the mean activation within each example close to 0 and the acti... | def __call__(self, x):
"""
Applies layer normalization on the input. It normalizes the activations of the layer for each given example in
a batch independently, rather than across a batch like Batch Normalization. i.e. applies a transformation that
maintains the mean activation within ea... | [
"def",
"__call__",
"(",
"self",
",",
"x",
")",
":",
"mean",
"=",
"jnp",
".",
"mean",
"(",
"x",
",",
"axis",
"=",
"-",
"1",
",",
"keepdims",
"=",
"True",
")",
"mean2",
"=",
"jnp",
".",
"mean",
"(",
"jax",
".",
"lax",
".",
"square",
"(",
"x",
... | [
113,
4
] | [
136,
16
] | python | en | ['en', 'error', 'th'] | False |
update | (input_dict, update_source) | Deep update a dictionary.
Async friendly.
| Deep update a dictionary. | def update(input_dict, update_source):
"""Deep update a dictionary.
Async friendly.
"""
for key, val in update_source.items():
if isinstance(val, Mapping):
recurse = update(input_dict.get(key, {}), val)
input_dict[key] = recurse
else:
input_dict[key] ... | [
"def",
"update",
"(",
"input_dict",
",",
"update_source",
")",
":",
"for",
"key",
",",
"val",
"in",
"update_source",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"Mapping",
")",
":",
"recurse",
"=",
"update",
"(",
"input_dict",
"."... | [
31,
0
] | [
42,
21
] | python | en | ['it', 'lb', 'en'] | False |
async_get_service | (hass, config, discovery_info=None) | Get the Group notification service. | Get the Group notification service. | async def async_get_service(hass, config, discovery_info=None):
"""Get the Group notification service."""
return GroupNotifyPlatform(hass, config.get(CONF_SERVICES)) | [
"async",
"def",
"async_get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"return",
"GroupNotifyPlatform",
"(",
"hass",
",",
"config",
".",
"get",
"(",
"CONF_SERVICES",
")",
")"
] | [
45,
0
] | [
47,
63
] | python | en | ['en', 'en', 'en'] | True |
GroupNotifyPlatform.__init__ | (self, hass, entities) | Initialize the service. | Initialize the service. | def __init__(self, hass, entities):
"""Initialize the service."""
self.hass = hass
self.entities = entities | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"entities",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"entities",
"=",
"entities"
] | [
53,
4
] | [
56,
32
] | python | en | ['en', 'en', 'en'] | True |
GroupNotifyPlatform.async_send_message | (self, message="", **kwargs) | Send message to all entities in the group. | Send message to all entities in the group. | async def async_send_message(self, message="", **kwargs):
"""Send message to all entities in the group."""
payload = {ATTR_MESSAGE: message}
payload.update({key: val for key, val in kwargs.items() if val})
tasks = []
for entity in self.entities:
sending_payload = dee... | [
"async",
"def",
"async_send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"payload",
"=",
"{",
"ATTR_MESSAGE",
":",
"message",
"}",
"payload",
".",
"update",
"(",
"{",
"key",
":",
"val",
"for",
"key",
",",
"va... | [
58,
4
] | [
75,
37
] | python | en | ['en', 'en', 'en'] | True |
zigpy_cover_device | (zigpy_device_mock) | Zigpy cover device. | Zigpy cover device. | def zigpy_cover_device(zigpy_device_mock):
"""Zigpy cover device."""
endpoints = {
1: {
"device_type": zigpy.profiles.zha.DeviceType.IAS_ZONE,
"in_clusters": [closures.WindowCovering.cluster_id],
"out_clusters": [],
}
}
return zigpy_device_mock(endpoi... | [
"def",
"zigpy_cover_device",
"(",
"zigpy_device_mock",
")",
":",
"endpoints",
"=",
"{",
"1",
":",
"{",
"\"device_type\"",
":",
"zigpy",
".",
"profiles",
".",
"zha",
".",
"DeviceType",
".",
"IAS_ZONE",
",",
"\"in_clusters\"",
":",
"[",
"closures",
".",
"Windo... | [
39,
0
] | [
49,
39
] | python | en | ['nl', 'en', 'en'] | True |
zigpy_cover_remote | (zigpy_device_mock) | Zigpy cover remote device. | Zigpy cover remote device. | def zigpy_cover_remote(zigpy_device_mock):
"""Zigpy cover remote device."""
endpoints = {
1: {
"device_type": zigpy.profiles.zha.DeviceType.WINDOW_COVERING_CONTROLLER,
"in_clusters": [],
"out_clusters": [closures.WindowCovering.cluster_id],
}
}
return... | [
"def",
"zigpy_cover_remote",
"(",
"zigpy_device_mock",
")",
":",
"endpoints",
"=",
"{",
"1",
":",
"{",
"\"device_type\"",
":",
"zigpy",
".",
"profiles",
".",
"zha",
".",
"DeviceType",
".",
"WINDOW_COVERING_CONTROLLER",
",",
"\"in_clusters\"",
":",
"[",
"]",
",... | [
53,
0
] | [
63,
39
] | python | en | ['fr', 'en', 'en'] | True |
zigpy_shade_device | (zigpy_device_mock) | Zigpy shade device. | Zigpy shade device. | def zigpy_shade_device(zigpy_device_mock):
"""Zigpy shade device."""
endpoints = {
1: {
"device_type": zigpy.profiles.zha.DeviceType.SHADE,
"in_clusters": [
closures.Shade.cluster_id,
general.LevelControl.cluster_id,
general.OnOff.... | [
"def",
"zigpy_shade_device",
"(",
"zigpy_device_mock",
")",
":",
"endpoints",
"=",
"{",
"1",
":",
"{",
"\"device_type\"",
":",
"zigpy",
".",
"profiles",
".",
"zha",
".",
"DeviceType",
".",
"SHADE",
",",
"\"in_clusters\"",
":",
"[",
"closures",
".",
"Shade",
... | [
67,
0
] | [
81,
39
] | python | en | ['fr', 'en', 'en'] | True |
zigpy_keen_vent | (zigpy_device_mock) | Zigpy Keen Vent device. | Zigpy Keen Vent device. | def zigpy_keen_vent(zigpy_device_mock):
"""Zigpy Keen Vent device."""
endpoints = {
1: {
"device_type": zigpy.profiles.zha.DeviceType.LEVEL_CONTROLLABLE_OUTPUT,
"in_clusters": [general.LevelControl.cluster_id, general.OnOff.cluster_id],
"out_clusters": [],
}
... | [
"def",
"zigpy_keen_vent",
"(",
"zigpy_device_mock",
")",
":",
"endpoints",
"=",
"{",
"1",
":",
"{",
"\"device_type\"",
":",
"zigpy",
".",
"profiles",
".",
"zha",
".",
"DeviceType",
".",
"LEVEL_CONTROLLABLE_OUTPUT",
",",
"\"in_clusters\"",
":",
"[",
"general",
... | [
85,
0
] | [
97,
5
] | python | en | ['nl', 'en', 'en'] | True |
test_cover | (m1, hass, zha_device_joined_restored, zigpy_cover_device) | Test zha cover platform. | Test zha cover platform. | async def test_cover(m1, hass, zha_device_joined_restored, zigpy_cover_device):
"""Test zha cover platform."""
# load up cover domain
cluster = zigpy_cover_device.endpoints.get(1).window_covering
cluster.PLUGGED_ATTR_READS = {"current_position_lift_percentage": 100}
zha_device = await zha_device_jo... | [
"async",
"def",
"test_cover",
"(",
"m1",
",",
"hass",
",",
"zha_device_joined_restored",
",",
"zigpy_cover_device",
")",
":",
"# load up cover domain",
"cluster",
"=",
"zigpy_cover_device",
".",
"endpoints",
".",
"get",
"(",
"1",
")",
".",
"window_covering",
"clus... | [
103,
0
] | [
190,
57
] | python | bg-Latn | ['br', 'bg-Latn', 'pl'] | False |
test_shade | (hass, zha_device_joined_restored, zigpy_shade_device) | Test zha cover platform for shade device type. | Test zha cover platform for shade device type. | async def test_shade(hass, zha_device_joined_restored, zigpy_shade_device):
"""Test zha cover platform for shade device type."""
# load up cover domain
zha_device = await zha_device_joined_restored(zigpy_shade_device)
cluster_on_off = zigpy_shade_device.endpoints.get(1).on_off
cluster_level = zigp... | [
"async",
"def",
"test_shade",
"(",
"hass",
",",
"zha_device_joined_restored",
",",
"zigpy_shade_device",
")",
":",
"# load up cover domain",
"zha_device",
"=",
"await",
"zha_device_joined_restored",
"(",
"zigpy_shade_device",
")",
"cluster_on_off",
"=",
"zigpy_shade_device"... | [
193,
0
] | [
317,
72
] | python | en | ['br', 'en', 'en'] | True |
test_restore_state | (hass, zha_device_restored, zigpy_shade_device) | Ensure states are restored on startup. | Ensure states are restored on startup. | async def test_restore_state(hass, zha_device_restored, zigpy_shade_device):
"""Ensure states are restored on startup."""
mock_restore_cache(
hass,
(
State(
"cover.fakemanufacturer_fakemodel_e769900a_level_on_off_shade",
STATE_OPEN,
{A... | [
"async",
"def",
"test_restore_state",
"(",
"hass",
",",
"zha_device_restored",
",",
"zigpy_shade_device",
")",
":",
"mock_restore_cache",
"(",
"hass",
",",
"(",
"State",
"(",
"\"cover.fakemanufacturer_fakemodel_e769900a_level_on_off_shade\"",
",",
"STATE_OPEN",
",",
"{",
... | [
320,
0
] | [
342,
77
] | python | en | ['en', 'en', 'en'] | True |
test_keen_vent | (hass, zha_device_joined_restored, zigpy_keen_vent) | Test keen vent. | Test keen vent. | async def test_keen_vent(hass, zha_device_joined_restored, zigpy_keen_vent):
"""Test keen vent."""
# load up cover domain
zha_device = await zha_device_joined_restored(zigpy_keen_vent)
cluster_on_off = zigpy_keen_vent.endpoints.get(1).on_off
cluster_level = zigpy_keen_vent.endpoints.get(1).level
... | [
"async",
"def",
"test_keen_vent",
"(",
"hass",
",",
"zha_device_joined_restored",
",",
"zigpy_keen_vent",
")",
":",
"# load up cover domain",
"zha_device",
"=",
"await",
"zha_device_joined_restored",
"(",
"zigpy_keen_vent",
")",
"cluster_on_off",
"=",
"zigpy_keen_vent",
"... | [
345,
0
] | [
396,
82
] | python | lb | ['nl', 'lb', 'sw'] | False |
test_cover_remote | (hass, zha_device_joined_restored, zigpy_cover_remote) | Test zha cover remote. | Test zha cover remote. | async def test_cover_remote(hass, zha_device_joined_restored, zigpy_cover_remote):
"""Test zha cover remote."""
# load up cover domain
await zha_device_joined_restored(zigpy_cover_remote)
cluster = zigpy_cover_remote.endpoints[1].out_clusters[
closures.WindowCovering.cluster_id
]
zha_e... | [
"async",
"def",
"test_cover_remote",
"(",
"hass",
",",
"zha_device_joined_restored",
",",
"zigpy_cover_remote",
")",
":",
"# load up cover domain",
"await",
"zha_device_joined_restored",
"(",
"zigpy_cover_remote",
")",
"cluster",
"=",
"zigpy_cover_remote",
".",
"endpoints",... | [
399,
0
] | [
424,
59
] | python | br | ['br', 'it', 'en'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Lyft sensor. | Set up the Lyft sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Lyft sensor."""
auth_flow = ClientCredentialGrant(
client_id=config.get(CONF_CLIENT_ID),
client_secret=config.get(CONF_CLIENT_SECRET),
scopes="public",
is_sandbox_mode=False,
)
try:
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"auth_flow",
"=",
"ClientCredentialGrant",
"(",
"client_id",
"=",
"config",
".",
"get",
"(",
"CONF_CLIENT_ID",
")",
",",
"client_secret",
"=... | [
40,
0
] | [
73,
27
] | python | en | ['en', 'ru', 'en'] | True |
LyftSensor.__init__ | (self, sensorType, products, product_id, product) | Initialize the Lyft sensor. | Initialize the Lyft sensor. | def __init__(self, sensorType, products, product_id, product):
"""Initialize the Lyft sensor."""
self.data = products
self._product_id = product_id
self._product = product
self._sensortype = sensorType
self._name = f"{self._product['display_name']} {self._sensortype}"
... | [
"def",
"__init__",
"(",
"self",
",",
"sensorType",
",",
"products",
",",
"product_id",
",",
"product",
")",
":",
"self",
".",
"data",
"=",
"products",
"self",
".",
"_product_id",
"=",
"product_id",
"self",
".",
"_product",
"=",
"product",
"self",
".",
"_... | [
79,
4
] | [
94,
26
] | python | en | ['en', 'ro', 'en'] | True |
LyftSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
97,
4
] | [
99,
25
] | python | en | ['en', 'mi', 'en'] | True |
LyftSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
102,
4
] | [
104,
26
] | python | en | ['en', 'en', 'en'] | True |
LyftSensor.unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
107,
4
] | [
109,
40
] | python | en | ['en', 'en', 'en'] | True |
LyftSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
params = {
"Product ID": self._product["ride_type"],
"Product display name": self._product["display_name"],
"Vehicle Capacity": self._product["seats"],
}
if self._product.get("prici... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"params",
"=",
"{",
"\"Product ID\"",
":",
"self",
".",
"_product",
"[",
"\"ride_type\"",
"]",
",",
"\"Product display name\"",
":",
"self",
".",
"_product",
"[",
"\"display_name\"",
"]",
",",
"\"Vehicle C... | [
112,
4
] | [
151,
65
] | python | en | ['en', 'en', 'en'] | True |
LyftSensor.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
154,
4
] | [
156,
19
] | python | en | ['en', 'en', 'en'] | True |
LyftSensor.update | (self) | Get the latest data from the Lyft API and update the states. | Get the latest data from the Lyft API and update the states. | def update(self):
"""Get the latest data from the Lyft API and update the states."""
self.data.update()
try:
self._product = self.data.products[self._product_id]
except KeyError:
return
self._state = None
if self._sensortype == "time":
... | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"data",
".",
"update",
"(",
")",
"try",
":",
"self",
".",
"_product",
"=",
"self",
".",
"data",
".",
"products",
"[",
"self",
".",
"_product_id",
"]",
"except",
"KeyError",
":",
"return",
"self",
... | [
158,
4
] | [
185,
17
] | python | en | ['en', 'en', 'en'] | True |
LyftEstimate.__init__ | (
self,
session,
start_latitude,
start_longitude,
end_latitude=None,
end_longitude=None,
) | Initialize the LyftEstimate object. | Initialize the LyftEstimate object. | def __init__(
self,
session,
start_latitude,
start_longitude,
end_latitude=None,
end_longitude=None,
):
"""Initialize the LyftEstimate object."""
self._session = session
self.start_latitude = start_latitude
self.start_longitude = start_... | [
"def",
"__init__",
"(",
"self",
",",
"session",
",",
"start_latitude",
",",
"start_longitude",
",",
"end_latitude",
"=",
"None",
",",
"end_longitude",
"=",
"None",
",",
")",
":",
"self",
".",
"_session",
"=",
"session",
"self",
".",
"start_latitude",
"=",
... | [
191,
4
] | [
205,
28
] | python | en | ['en', 'pl', 'en'] | True |
LyftEstimate.update | (self) | Get the latest product info and estimates from the Lyft API. | Get the latest product info and estimates from the Lyft API. | def update(self):
"""Get the latest product info and estimates from the Lyft API."""
try:
self.fetch_data()
except APIError as exc:
_LOGGER.error("Error fetching Lyft data: %s", exc) | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"fetch_data",
"(",
")",
"except",
"APIError",
"as",
"exc",
":",
"_LOGGER",
".",
"error",
"(",
"\"Error fetching Lyft data: %s\"",
",",
"exc",
")"
] | [
208,
4
] | [
214,
62
] | python | en | ['en', 'en', 'en'] | True |
LyftEstimate.fetch_data | (self) | Get the latest product info and estimates from the Lyft API. | Get the latest product info and estimates from the Lyft API. | def fetch_data(self):
"""Get the latest product info and estimates from the Lyft API."""
client = LyftRidesClient(self._session)
self.products = {}
products_response = client.get_ride_types(
self.start_latitude, self.start_longitude
)
products = products_r... | [
"def",
"fetch_data",
"(",
"self",
")",
":",
"client",
"=",
"LyftRidesClient",
"(",
"self",
".",
"_session",
")",
"self",
".",
"products",
"=",
"{",
"}",
"products_response",
"=",
"client",
".",
"get_ride_types",
"(",
"self",
".",
"start_latitude",
",",
"se... | [
216,
4
] | [
255,
60
] | python | en | ['en', 'en', 'en'] | True |
get_pairs | (word) |
Return set of symbol pairs in a word. word is represented as tuple of symbols (symbols being variable-length
strings)
|
Return set of symbol pairs in a word. word is represented as tuple of symbols (symbols being variable-length
strings)
| def get_pairs(word):
"""
Return set of symbol pairs in a word. word is represented as tuple of symbols (symbols being variable-length
strings)
"""
pairs = set()
prev_char = word[0]
for char in word[1:]:
pairs.add((prev_char, char))
prev_char = char
return pairs | [
"def",
"get_pairs",
"(",
"word",
")",
":",
"pairs",
"=",
"set",
"(",
")",
"prev_char",
"=",
"word",
"[",
"0",
"]",
"for",
"char",
"in",
"word",
"[",
"1",
":",
"]",
":",
"pairs",
".",
"add",
"(",
"(",
"prev_char",
",",
"char",
")",
")",
"prev_ch... | [
429,
0
] | [
439,
16
] | python | en | ['en', 'error', 'th'] | False |
lowercase_and_remove_accent | (text) |
Lowercase and strips accents from a piece of text based on
https://github.com/facebookresearch/XLM/blob/master/tools/lowercase_and_remove_accent.py
|
Lowercase and strips accents from a piece of text based on
https://github.com/facebookresearch/XLM/blob/master/tools/lowercase_and_remove_accent.py
| def lowercase_and_remove_accent(text):
"""
Lowercase and strips accents from a piece of text based on
https://github.com/facebookresearch/XLM/blob/master/tools/lowercase_and_remove_accent.py
"""
text = " ".join(text)
text = text.lower()
text = unicodedata.normalize("NFD", text)
output = ... | [
"def",
"lowercase_and_remove_accent",
"(",
"text",
")",
":",
"text",
"=",
"\" \"",
".",
"join",
"(",
"text",
")",
"text",
"=",
"text",
".",
"lower",
"(",
")",
"text",
"=",
"unicodedata",
".",
"normalize",
"(",
"\"NFD\"",
",",
"text",
")",
"output",
"="... | [
442,
0
] | [
456,
45
] | python | en | ['en', 'error', 'th'] | False |
replace_unicode_punct | (text) |
Port of https://github.com/moses-smt/mosesdecoder/blob/master/scripts/tokenizer/replace-unicode-punctuation.perl
|
Port of https://github.com/moses-smt/mosesdecoder/blob/master/scripts/tokenizer/replace-unicode-punctuation.perl
| def replace_unicode_punct(text):
"""
Port of https://github.com/moses-smt/mosesdecoder/blob/master/scripts/tokenizer/replace-unicode-punctuation.perl
"""
text = text.replace(",", ",")
text = re.sub(r"。\s*", ". ", text)
text = text.replace("、", ",")
text = text.replace("”", '"')
text = te... | [
"def",
"replace_unicode_punct",
"(",
"text",
")",
":",
"text",
"=",
"text",
".",
"replace",
"(",
"\",\", ",
"\"",
"\")",
"",
"text",
"=",
"re",
".",
"sub",
"(",
"r\"。\\s*\", ",
"\"",
" \", ",
"t",
"xt)",
"",
"text",
"=",
"text",
".",
"replace",
"(",
... | [
459,
0
] | [
499,
15
] | python | en | ['en', 'error', 'th'] | False |
remove_non_printing_char | (text) |
Port of https://github.com/moses-smt/mosesdecoder/blob/master/scripts/tokenizer/remove-non-printing-char.perl
|
Port of https://github.com/moses-smt/mosesdecoder/blob/master/scripts/tokenizer/remove-non-printing-char.perl
| def remove_non_printing_char(text):
"""
Port of https://github.com/moses-smt/mosesdecoder/blob/master/scripts/tokenizer/remove-non-printing-char.perl
"""
output = []
for char in text:
cat = unicodedata.category(char)
if cat.startswith("C"):
continue
output.append(... | [
"def",
"remove_non_printing_char",
"(",
"text",
")",
":",
"output",
"=",
"[",
"]",
"for",
"char",
"in",
"text",
":",
"cat",
"=",
"unicodedata",
".",
"category",
"(",
"char",
")",
"if",
"cat",
".",
"startswith",
"(",
"\"C\"",
")",
":",
"continue",
"outp... | [
502,
0
] | [
512,
26
] | python | en | ['en', 'error', 'th'] | False |
romanian_preprocessing | (text) | Sennrich's WMT16 scripts for Romanian preprocessing, used by model `xlm-mlm-enro-1024` | Sennrich's WMT16 scripts for Romanian preprocessing, used by model `xlm-mlm-enro-1024` | def romanian_preprocessing(text):
"""Sennrich's WMT16 scripts for Romanian preprocessing, used by model `xlm-mlm-enro-1024`"""
# https://github.com/rsennrich/wmt16-scripts/blob/master/preprocess/normalise-romanian.py
text = text.replace("\u015e", "\u0218").replace("\u015f", "\u0219")
text = text.replace... | [
"def",
"romanian_preprocessing",
"(",
"text",
")",
":",
"# https://github.com/rsennrich/wmt16-scripts/blob/master/preprocess/normalise-romanian.py",
"text",
"=",
"text",
".",
"replace",
"(",
"\"\\u015e\"",
",",
"\"\\u0218\"",
")",
".",
"replace",
"(",
"\"\\u015f\"",
",",
... | [
515,
0
] | [
526,
15
] | python | en | ['en', 'cy', 'en'] | True |
XLMTokenizer._tokenize | (self, text, lang="en", bypass_tokenizer=False) |
Tokenize a string given language code. For Chinese, Japanese and Thai, we use a language specific
tokenizerself. Otherwise, we use Moses.
Details of tokenization:
- [sacremoses](https://github.com/alvations/sacremoses): port of Moses
- Install with `pip install sacremo... |
Tokenize a string given language code. For Chinese, Japanese and Thai, we use a language specific
tokenizerself. Otherwise, we use Moses. | def _tokenize(self, text, lang="en", bypass_tokenizer=False):
"""
Tokenize a string given language code. For Chinese, Japanese and Thai, we use a language specific
tokenizerself. Otherwise, we use Moses.
Details of tokenization:
- [sacremoses](https://github.com/alvations/s... | [
"def",
"_tokenize",
"(",
"self",
",",
"text",
",",
"lang",
"=",
"\"en\"",
",",
"bypass_tokenizer",
"=",
"False",
")",
":",
"if",
"lang",
"and",
"self",
".",
"lang2id",
"and",
"lang",
"not",
"in",
"self",
".",
"lang2id",
":",
"logger",
".",
"error",
"... | [
749,
4
] | [
846,
27
] | python | en | ['en', 'error', 'th'] | False |
XLMTokenizer._convert_token_to_id | (self, token) | Converts a token (str) in an id using the vocab. | Converts a token (str) in an id using the vocab. | def _convert_token_to_id(self, token):
""" Converts a token (str) in an id using the vocab. """
return self.encoder.get(token, self.encoder.get(self.unk_token)) | [
"def",
"_convert_token_to_id",
"(",
"self",
",",
"token",
")",
":",
"return",
"self",
".",
"encoder",
".",
"get",
"(",
"token",
",",
"self",
".",
"encoder",
".",
"get",
"(",
"self",
".",
"unk_token",
")",
")"
] | [
848,
4
] | [
850,
72
] | python | en | ['en', 'en', 'en'] | True |
XLMTokenizer._convert_id_to_token | (self, index) | Converts an index (integer) in a token (str) using the vocab. | Converts an index (integer) in a token (str) using the vocab. | def _convert_id_to_token(self, index):
"""Converts an index (integer) in a token (str) using the vocab."""
return self.decoder.get(index, self.unk_token) | [
"def",
"_convert_id_to_token",
"(",
"self",
",",
"index",
")",
":",
"return",
"self",
".",
"decoder",
".",
"get",
"(",
"index",
",",
"self",
".",
"unk_token",
")"
] | [
852,
4
] | [
854,
54
] | python | en | ['en', 'en', 'en'] | True |
XLMTokenizer.convert_tokens_to_string | (self, tokens) | Converts a sequence of tokens (string) in a single string. | Converts a sequence of tokens (string) in a single string. | def convert_tokens_to_string(self, tokens):
""" Converts a sequence of tokens (string) in a single string. """
out_string = "".join(tokens).replace("</w>", " ").strip()
return out_string | [
"def",
"convert_tokens_to_string",
"(",
"self",
",",
"tokens",
")",
":",
"out_string",
"=",
"\"\"",
".",
"join",
"(",
"tokens",
")",
".",
"replace",
"(",
"\"</w>\"",
",",
"\" \"",
")",
".",
"strip",
"(",
")",
"return",
"out_string"
] | [
856,
4
] | [
859,
25
] | python | en | ['en', 'en', 'en'] | True |
XLMTokenizer.build_inputs_with_special_tokens | (
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) |
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. An XLM sequence has the following format:
- single sequence: ``<s> X </s>``
- pair of sequences: ``<s> A </s> B </s>``
Args:
token... |
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. An XLM sequence has the following format: | def build_inputs_with_special_tokens(
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) -> List[int]:
"""
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. An XLM sequence has t... | [
"def",
"build_inputs_with_special_tokens",
"(",
"self",
",",
"token_ids_0",
":",
"List",
"[",
"int",
"]",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"int",
"]",
":",
"bos",
"=",
"[",
"... | [
861,
4
] | [
886,
58
] | python | en | ['en', 'error', 'th'] | False |
XLMTokenizer.get_special_tokens_mask | (
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False
) |
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer ``prepare_for_model`` method.
Args:
token_ids_0 (:obj:`List[int]`):
List of IDs.
token_ids_1 (:obj:`List[int]`,... |
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer ``prepare_for_model`` method. | def get_special_tokens_mask(
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False
) -> List[int]:
"""
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens ... | [
"def",
"get_special_tokens_mask",
"(",
"self",
",",
"token_ids_0",
":",
"List",
"[",
"int",
"]",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
",",
"already_has_special_tokens",
":",
"bool",
"=",
"False",
")",
"->",
... | [
888,
4
] | [
922,
51
] | python | en | ['en', 'error', 'th'] | False |
XLMTokenizer.create_token_type_ids_from_sequences | (
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) |
Create a mask from the two sequences passed to be used in a sequence-pair classification task. An XLM sequence
pair mask has the following format:
::
0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1
| first sequence | second sequence |
If :obj:`token_ids_1` is :obj:... |
Create a mask from the two sequences passed to be used in a sequence-pair classification task. An XLM sequence
pair mask has the following format: | def create_token_type_ids_from_sequences(
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) -> List[int]:
"""
Create a mask from the two sequences passed to be used in a sequence-pair classification task. An XLM sequence
pair mask has the following format:
... | [
"def",
"create_token_type_ids_from_sequences",
"(",
"self",
",",
"token_ids_0",
":",
"List",
"[",
"int",
"]",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"int",
"]",
":",
"sep",
"=",
"[",... | [
924,
4
] | [
952,
80
] | python | en | ['en', 'error', 'th'] | False |
get_base_arg_parser | () | Get a base argument parser. | Get a base argument parser. | def get_base_arg_parser() -> argparse.ArgumentParser:
"""Get a base argument parser."""
parser = argparse.ArgumentParser(description="Home Assistant Translations")
parser.add_argument(
"action",
type=str,
choices=["clean", "develop", "download", "frontend", "migrate", "upload"],
... | [
"def",
"get_base_arg_parser",
"(",
")",
"->",
"argparse",
".",
"ArgumentParser",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Home Assistant Translations\"",
")",
"parser",
".",
"add_argument",
"(",
"\"action\"",
",",
"type",
... | [
9,
0
] | [
18,
17
] | python | da | ['fr', 'da', 'en'] | False |
get_lokalise_token | () | Get lokalise token. | Get lokalise token. | def get_lokalise_token():
"""Get lokalise token."""
token = os.environ.get("LOKALISE_TOKEN")
if token is not None:
return token
token_file = pathlib.Path(".lokalise_token")
if not token_file.is_file():
raise ExitApp(
"Lokalise token not found in env LOKALISE_TOKEN or f... | [
"def",
"get_lokalise_token",
"(",
")",
":",
"token",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"LOKALISE_TOKEN\"",
")",
"if",
"token",
"is",
"not",
"None",
":",
"return",
"token",
"token_file",
"=",
"pathlib",
".",
"Path",
"(",
"\".lokalise_token\"",
"... | [
21,
0
] | [
35,
41
] | python | nl | ['nl', 'no', 'ur'] | False |
get_current_branch | () | Get current branch. | Get current branch. | def get_current_branch():
"""Get current branch."""
return (
subprocess.run(
["git", "rev-parse", "--abbrev-ref", "HEAD"], stdout=subprocess.PIPE
)
.stdout.decode()
.strip()
) | [
"def",
"get_current_branch",
"(",
")",
":",
"return",
"(",
"subprocess",
".",
"run",
"(",
"[",
"\"git\"",
",",
"\"rev-parse\"",
",",
"\"--abbrev-ref\"",
",",
"\"HEAD\"",
"]",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
")",
".",
"stdout",
".",
"decode",... | [
38,
0
] | [
46,
5
] | python | en | ['en', 'de', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Open Exchange Rates sensor. | Set up the Open Exchange Rates sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Open Exchange Rates sensor."""
name = config.get(CONF_NAME)
api_key = config.get(CONF_API_KEY)
base = config.get(CONF_BASE)
quote = config.get(CONF_QUOTE)
parameters = {"base": base, "app_id": api_key}
rest ... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"name",
"=",
"config",
".",
"get",
"(",
"CONF_NAME",
")",
"api_key",
"=",
"config",
".",
"get",
"(",
"CONF_API_KEY",
")",
"base",
"=",... | [
40,
0
] | [
57,
68
] | python | en | ['en', 'nl', 'en'] | True |
OpenexchangeratesSensor.__init__ | (self, rest, name, quote) | Initialize the sensor. | Initialize the sensor. | def __init__(self, rest, name, quote):
"""Initialize the sensor."""
self.rest = rest
self._name = name
self._quote = quote
self._state = None | [
"def",
"__init__",
"(",
"self",
",",
"rest",
",",
"name",
",",
"quote",
")",
":",
"self",
".",
"rest",
"=",
"rest",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_quote",
"=",
"quote",
"self",
".",
"_state",
"=",
"None"
] | [
63,
4
] | [
68,
26
] | python | en | ['en', 'en', 'en'] | True |
OpenexchangeratesSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
71,
4
] | [
73,
25
] | python | en | ['en', 'mi', 'en'] | True |
OpenexchangeratesSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
76,
4
] | [
78,
26
] | python | en | ['en', 'en', 'en'] | True |
OpenexchangeratesSensor.device_state_attributes | (self) | Return other attributes of the sensor. | Return other attributes of the sensor. | def device_state_attributes(self):
"""Return other attributes of the sensor."""
attr = self.rest.data
attr[ATTR_ATTRIBUTION] = ATTRIBUTION
return attr | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attr",
"=",
"self",
".",
"rest",
".",
"data",
"attr",
"[",
"ATTR_ATTRIBUTION",
"]",
"=",
"ATTRIBUTION",
"return",
"attr"
] | [
81,
4
] | [
86,
19
] | python | en | ['en', 'en', 'en'] | True |
OpenexchangeratesSensor.update | (self) | Update current conditions. | Update current conditions. | def update(self):
"""Update current conditions."""
self.rest.update()
value = self.rest.data
self._state = round(value[str(self._quote)], 4) | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"rest",
".",
"update",
"(",
")",
"value",
"=",
"self",
".",
"rest",
".",
"data",
"self",
".",
"_state",
"=",
"round",
"(",
"value",
"[",
"str",
"(",
"self",
".",
"_quote",
")",
"]",
",",
"4",... | [
88,
4
] | [
92,
55
] | python | en | ['en', 'en', 'en'] | True |
OpenexchangeratesData.__init__ | (self, resource, parameters, quote) | Initialize the data object. | Initialize the data object. | def __init__(self, resource, parameters, quote):
"""Initialize the data object."""
self._resource = resource
self._parameters = parameters
self._quote = quote
self.data = None | [
"def",
"__init__",
"(",
"self",
",",
"resource",
",",
"parameters",
",",
"quote",
")",
":",
"self",
".",
"_resource",
"=",
"resource",
"self",
".",
"_parameters",
"=",
"parameters",
"self",
".",
"_quote",
"=",
"quote",
"self",
".",
"data",
"=",
"None"
] | [
98,
4
] | [
103,
24
] | python | en | ['en', 'en', 'en'] | True |
OpenexchangeratesData.update | (self) | Get the latest data from openexchangerates.org. | Get the latest data from openexchangerates.org. | def update(self):
"""Get the latest data from openexchangerates.org."""
try:
result = requests.get(self._resource, params=self._parameters, timeout=10)
self.data = result.json()["rates"]
except requests.exceptions.HTTPError:
_LOGGER.error("Check the Openexchan... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"result",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"_resource",
",",
"params",
"=",
"self",
".",
"_parameters",
",",
"timeout",
"=",
"10",
")",
"self",
".",
"data",
"=",
"result",
".",
"json... | [
106,
4
] | [
114,
24
] | python | en | ['en', 'en', 'en'] | True |
ExperimentConfig.__init__ | (self, config_filename: str, adopt_auxiliaries=True) |
Parses DN3 configuration files. Checking the DN3 token for listed datasets.
Parameters
----------
config_filename : str
String for path to yaml formatted configuration file
adopt_auxiliaries : bool
For any additional tokens... |
Parses DN3 configuration files. Checking the DN3 token for listed datasets. | def __init__(self, config_filename: str, adopt_auxiliaries=True):
"""
Parses DN3 configuration files. Checking the DN3 token for listed datasets.
Parameters
----------
config_filename : str
String for path to yaml formatted configuration file
ad... | [
"def",
"__init__",
"(",
"self",
",",
"config_filename",
":",
"str",
",",
"adopt_auxiliaries",
"=",
"True",
")",
":",
"with",
"open",
"(",
"config_filename",
",",
"'r'",
")",
"as",
"fio",
":",
"self",
".",
"_original_config",
"=",
"yaml",
".",
"load",
"("... | [
74,
4
] | [
131,
52
] | python | en | ['en', 'error', 'th'] | False |
DatasetConfig.__init__ | (self, name: str, config: dict, adopt_auxiliaries=True, ext_handlers=None, deep1010=None,
samples=None, sfreq=None, preload=False, return_trial_ids=False) |
Parses dataset entries in DN3 config
Parameters
----------
name : str
The name of the dataset specified in the config. Will be replaced if the optional `name` field is present
in the config.
config : dict
The configuration entry for... |
Parses dataset entries in DN3 config | def __init__(self, name: str, config: dict, adopt_auxiliaries=True, ext_handlers=None, deep1010=None,
samples=None, sfreq=None, preload=False, return_trial_ids=False):
"""
Parses dataset entries in DN3 config
Parameters
----------
name : str
The n... | [
"def",
"__init__",
"(",
"self",
",",
"name",
":",
"str",
",",
"config",
":",
"dict",
",",
"adopt_auxiliaries",
"=",
"True",
",",
"ext_handlers",
"=",
"None",
",",
"deep1010",
"=",
"None",
",",
"samples",
"=",
"None",
",",
"sfreq",
"=",
"None",
",",
"... | [
138,
4
] | [
287,
61
] | python | en | ['en', 'error', 'th'] | False |
DatasetConfig.add_extension_handler | (self, extension: str, handler) |
Provide callable code to create a raw instance from sessions with certain file extensions. This is useful for
handling of custom file formats, while preserving a consistent experiment framework.
Parameters
----------
extension : str
An extension that includes... |
Provide callable code to create a raw instance from sessions with certain file extensions. This is useful for
handling of custom file formats, while preserving a consistent experiment framework. | def add_extension_handler(self, extension: str, handler):
"""
Provide callable code to create a raw instance from sessions with certain file extensions. This is useful for
handling of custom file formats, while preserving a consistent experiment framework.
Parameters
----------
... | [
"def",
"add_extension_handler",
"(",
"self",
",",
"extension",
":",
"str",
",",
"handler",
")",
":",
"assert",
"callable",
"(",
"handler",
")",
"self",
".",
"_extension_handlers",
"[",
"extension",
"]",
"=",
"handler"
] | [
301,
4
] | [
315,
53
] | python | en | ['en', 'error', 'th'] | False |
DatasetConfig.scan_toplevel | (self) |
Scan the provided toplevel for all files that may belong to the dataset.
Returns
-------
files: list
A listing of all the candidate filepaths (before excluding those that match exclusion criteria).
|
Scan the provided toplevel for all files that may belong to the dataset. | def scan_toplevel(self):
"""
Scan the provided toplevel for all files that may belong to the dataset.
Returns
-------
files: list
A listing of all the candidate filepaths (before excluding those that match exclusion criteria).
"""
files = list()
... | [
"def",
"scan_toplevel",
"(",
"self",
")",
":",
"files",
"=",
"list",
"(",
")",
"pbar",
"=",
"tqdm",
".",
"tqdm",
"(",
"self",
".",
"extensions",
",",
"desc",
"=",
"\"Scanning {}. If there are a lot of files, this may take a while...\"",
".",
"format",
"(",
"self... | [
317,
4
] | [
333,
20
] | python | en | ['en', 'error', 'th'] | False |
DatasetConfig.auto_mapping | (self, files=None, reset_exclusions=True) |
Generates a mapping of sessions and people of the dataset, assuming files are stored in the structure:
`toplevel`/(*optional - <version>)/<person-id>/<session-id>.{ext}
Parameters
-------
files : list
Optional list of files (convertible to `Path` objects, e.g. r... |
Generates a mapping of sessions and people of the dataset, assuming files are stored in the structure:
`toplevel`/(*optional - <version>)/<person-id>/<session-id>.{ext} | def auto_mapping(self, files=None, reset_exclusions=True):
"""
Generates a mapping of sessions and people of the dataset, assuming files are stored in the structure:
`toplevel`/(*optional - <version>)/<person-id>/<session-id>.{ext}
Parameters
-------
files : list
... | [
"def",
"auto_mapping",
"(",
"self",
",",
"files",
"=",
"None",
",",
"reset_exclusions",
"=",
"True",
")",
":",
"if",
"reset_exclusions",
":",
"self",
".",
"_excluded_people",
"=",
"list",
"(",
")",
"files",
"=",
"self",
".",
"scan_toplevel",
"(",
")",
"i... | [
383,
4
] | [
421,
22
] | python | en | ['en', 'error', 'th'] | False |
DatasetConfig.add_custom_raw_loader | (self, custom_loader) |
This is used to provide a custom implementation of taking a filename, and returning a :any:`mne.io.Raw()`
instance. If properly constructed, all further configuratron options, such as resampling, epoching, filtering
etc. should occur automatically.
This is used to load unconventional f... |
This is used to provide a custom implementation of taking a filename, and returning a :any:`mne.io.Raw()`
instance. If properly constructed, all further configuratron options, such as resampling, epoching, filtering
etc. should occur automatically. | def add_custom_raw_loader(self, custom_loader):
"""
This is used to provide a custom implementation of taking a filename, and returning a :any:`mne.io.Raw()`
instance. If properly constructed, all further configuratron options, such as resampling, epoching, filtering
etc. should occur au... | [
"def",
"add_custom_raw_loader",
"(",
"self",
",",
"custom_loader",
")",
":",
"assert",
"callable",
"(",
"custom_loader",
")",
"self",
".",
"_custom_raw_loader",
"=",
"custom_loader"
] | [
430,
4
] | [
452,
47
] | python | en | ['en', 'error', 'th'] | False |
DatasetConfig.add_progress_callbacks | (self, session_callback=None, thinker_callback=None) |
Add callbacks to be invoked on successful loading of session and/or thinker. Optionally, these can modify the
respective loaded instances.
Parameters
----------
session_callback:
A function that expects a single session argument and can modify the (or ... |
Add callbacks to be invoked on successful loading of session and/or thinker. Optionally, these can modify the
respective loaded instances. | def add_progress_callbacks(self, session_callback=None, thinker_callback=None):
"""
Add callbacks to be invoked on successful loading of session and/or thinker. Optionally, these can modify the
respective loaded instances.
Parameters
----------
session_callback:
... | [
"def",
"add_progress_callbacks",
"(",
"self",
",",
"session_callback",
"=",
"None",
",",
"thinker_callback",
"=",
"None",
")",
":",
"self",
".",
"_session_callback",
"=",
"session_callback",
"self",
".",
"_thinker_callback",
"=",
"thinker_callback"
] | [
454,
4
] | [
470,
49
] | python | en | ['en', 'error', 'th'] | False |
DatasetConfig.add_custom_thinker_loader | (self, thinker_loader) |
Add custom code to load a specific thinker from a set of session files.
Warnings
----------
For all intents and purposes, this circumvents most of the configuratron, and results in it being mostly
a tool for organizing dataset files. Most of the options are not leveraged and mu... |
Add custom code to load a specific thinker from a set of session files. | def add_custom_thinker_loader(self, thinker_loader):
"""
Add custom code to load a specific thinker from a set of session files.
Warnings
----------
For all intents and purposes, this circumvents most of the configuratron, and results in it being mostly
a tool for organi... | [
"def",
"add_custom_thinker_loader",
"(",
"self",
",",
"thinker_loader",
")",
":",
"self",
".",
"_custom_thinker_loader",
"=",
"thinker_loader"
] | [
595,
4
] | [
614,
52
] | python | en | ['en', 'error', 'th'] | False |
DatasetConfig.auto_construct_dataset | (self, mapping=None, **dsargs) |
This creates a dataset using the config values. If tlen and tmin are specified in the config, creates epoched
dataset, otherwise Raw.
Parameters
----------
mapping : dict, optional
A dict specifying a list of sessions (as paths to files) for each person_id in th... |
This creates a dataset using the config values. If tlen and tmin are specified in the config, creates epoched
dataset, otherwise Raw. | def auto_construct_dataset(self, mapping=None, **dsargs):
"""
This creates a dataset using the config values. If tlen and tmin are specified in the config, creates epoched
dataset, otherwise Raw.
Parameters
----------
mapping : dict, optional
A dict speci... | [
"def",
"auto_construct_dataset",
"(",
"self",
",",
"mapping",
"=",
"None",
",",
"*",
"*",
"dsargs",
")",
":",
"if",
"self",
".",
"dumped",
"is",
"not",
"None",
":",
"path",
"=",
"Path",
"(",
"self",
".",
"dumped",
")",
"if",
"path",
".",
"exists",
... | [
634,
4
] | [
710,
22
] | python | en | ['en', 'error', 'th'] | False |
RawOnTheFlyRecording.__init__ | (self, raw, tlen, file_loader, session_id=0, person_id=0, stride=1, ch_ind_picks=None,
decimate=1, **kwargs) |
This provides a workaround for the normal raw recording pipeline so that files are not loaded in any way until
they are needed. MNE's Raw object are too bloated for extremely large datasets, even without preloading.
Parameters
----------
raw
tlen
file_loader
... |
This provides a workaround for the normal raw recording pipeline so that files are not loaded in any way until
they are needed. MNE's Raw object are too bloated for extremely large datasets, even without preloading. | def __init__(self, raw, tlen, file_loader, session_id=0, person_id=0, stride=1, ch_ind_picks=None,
decimate=1, **kwargs):
"""
This provides a workaround for the normal raw recording pipeline so that files are not loaded in any way until
they are needed. MNE's Raw object are too ... | [
"def",
"__init__",
"(",
"self",
",",
"raw",
",",
"tlen",
",",
"file_loader",
",",
"session_id",
"=",
"0",
",",
"person_id",
"=",
"0",
",",
"stride",
"=",
"1",
",",
"ch_ind_picks",
"=",
"None",
",",
"decimate",
"=",
"1",
",",
"*",
"*",
"kwargs",
")"... | [
715,
4
] | [
734,
38
] | python | en | ['en', 'error', 'th'] | False |
ProjectedAdaptiveLogSoftmax.forward | (self, hidden, labels=None, keep_order=False) |
Params:
hidden :: [len*bsz x d_proj]
labels :: [len*bsz
Return:
if labels is None: out :: [len*bsz x n_tokens] log probabilities of tokens over the vocabulary else: out ::
[(len-1)*bsz] Negative log likelihood. We could replace this implementation by the... |
Params:
hidden :: [len*bsz x d_proj]
labels :: [len*bsz | def forward(self, hidden, labels=None, keep_order=False):
"""
Params:
hidden :: [len*bsz x d_proj]
labels :: [len*bsz
Return:
if labels is None: out :: [len*bsz x n_tokens] log probabilities of tokens over the vocabulary else: out ::
[(len-1)*bsz]... | [
"def",
"forward",
"(",
"self",
",",
"hidden",
",",
"labels",
"=",
"None",
",",
"keep_order",
"=",
"False",
")",
":",
"if",
"labels",
"is",
"not",
"None",
":",
"# Shift so that tokens < n predict n",
"hidden",
"=",
"hidden",
"[",
"...",
",",
":",
"-",
"1"... | [
85,
4
] | [
188,
18
] | python | en | ['en', 'error', 'th'] | False |
ProjectedAdaptiveLogSoftmax.log_prob | (self, hidden) | r"""
Computes log probabilities for all :math:`n\_classes` From:
https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/adaptive.p
Args:
hidden (Tensor): a minibatch of example
Returns:
log-probabilities of for each class :math:`c` in range :math:`0 <= ... | r"""
Computes log probabilities for all :math:`n\_classes` From:
https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/adaptive.p | def log_prob(self, hidden):
r"""
Computes log probabilities for all :math:`n\_classes` From:
https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/adaptive.p
Args:
hidden (Tensor): a minibatch of example
Returns:
log-probabilities of for each c... | [
"def",
"log_prob",
"(",
"self",
",",
"hidden",
")",
":",
"if",
"self",
".",
"n_clusters",
"==",
"0",
":",
"logit",
"=",
"self",
".",
"_compute_logit",
"(",
"hidden",
",",
"self",
".",
"out_layers",
"[",
"0",
"]",
".",
"weight",
",",
"self",
".",
"o... | [
190,
4
] | [
248,
22
] | python | cy | ['en', 'cy', 'hi'] | False |
setup | (hass, config) | Set up the notify_events component. | Set up the notify_events component. | def setup(hass, config):
"""Set up the notify_events component."""
hass.data[DOMAIN] = config[DOMAIN]
discovery.load_platform(hass, "notify", DOMAIN, {}, config)
return True | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"config",
"[",
"DOMAIN",
"]",
"discovery",
".",
"load_platform",
"(",
"hass",
",",
"\"notify\"",
",",
"DOMAIN",
",",
"{",
"}",
",",
"config",
")",
"... | [
14,
0
] | [
19,
15
] | python | en | ['en', 'en', 'en'] | True |
AvriConfigFlow._show_setup_form | (self, errors=None) | Show the setup form to the user. | Show the setup form to the user. | async def _show_setup_form(self, errors=None):
"""Show the setup form to the user."""
return self.async_show_form(
step_id="user",
data_schema=DATA_SCHEMA,
errors=errors or {},
) | [
"async",
"def",
"_show_setup_form",
"(",
"self",
",",
"errors",
"=",
"None",
")",
":",
"return",
"self",
".",
"async_show_form",
"(",
"step_id",
"=",
"\"user\"",
",",
"data_schema",
"=",
"DATA_SCHEMA",
",",
"errors",
"=",
"errors",
"or",
"{",
"}",
",",
"... | [
31,
4
] | [
37,
9
] | python | en | ['en', 'en', 'en'] | True |
AvriConfigFlow.async_step_user | (self, user_input=None) | Handle the initial step. | Handle the initial step. | async def async_step_user(self, user_input=None):
"""Handle the initial step."""
if user_input is None:
return await self._show_setup_form()
zip_code = user_input[CONF_ZIP_CODE].replace(" ", "").upper()
errors = {}
if user_input[CONF_HOUSE_NUMBER] <= 0:
... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"None",
":",
"return",
"await",
"self",
".",
"_show_setup_form",
"(",
")",
"zip_code",
"=",
"user_input",
"[",
"CONF_ZIP_CODE",
"]",
".",
"r... | [
39,
4
] | [
75,
9
] | python | en | ['en', 'en', 'en'] | True |
normalize_hkid | (hkid) | Normalize a hkid so that it is safe to compare with other normalized hkids. | Normalize a hkid so that it is safe to compare with other normalized hkids. | def normalize_hkid(hkid):
"""Normalize a hkid so that it is safe to compare with other normalized hkids."""
return hkid.lower() | [
"def",
"normalize_hkid",
"(",
"hkid",
")",
":",
"return",
"hkid",
".",
"lower",
"(",
")"
] | [
48,
0
] | [
50,
23
] | python | en | ['en', 'en', 'en'] | True |
find_existing_host | (hass, serial) | Return a set of the configured hosts. | Return a set of the configured hosts. | def find_existing_host(hass, serial):
"""Return a set of the configured hosts."""
for entry in hass.config_entries.async_entries(DOMAIN):
if entry.data.get("AccessoryPairingID") == serial:
return entry | [
"def",
"find_existing_host",
"(",
"hass",
",",
"serial",
")",
":",
"for",
"entry",
"in",
"hass",
".",
"config_entries",
".",
"async_entries",
"(",
"DOMAIN",
")",
":",
"if",
"entry",
".",
"data",
".",
"get",
"(",
"\"AccessoryPairingID\"",
")",
"==",
"serial... | [
54,
0
] | [
58,
24
] | python | en | ['en', 'en', 'en'] | True |
ensure_pin_format | (pin) |
Ensure a pin code is correctly formatted.
Ensures a pin code is in the format 111-11-111. Handles codes with and without dashes.
If incorrect code is entered, an exception is raised.
|
Ensure a pin code is correctly formatted. | def ensure_pin_format(pin):
"""
Ensure a pin code is correctly formatted.
Ensures a pin code is in the format 111-11-111. Handles codes with and without dashes.
If incorrect code is entered, an exception is raised.
"""
match = PIN_FORMAT.search(pin.strip())
if not match:
raise aioh... | [
"def",
"ensure_pin_format",
"(",
"pin",
")",
":",
"match",
"=",
"PIN_FORMAT",
".",
"search",
"(",
"pin",
".",
"strip",
"(",
")",
")",
"if",
"not",
"match",
":",
"raise",
"aiohomekit",
".",
"exceptions",
".",
"MalformedPinError",
"(",
"f\"Invalid PIN code f{p... | [
61,
0
] | [
75,
35
] | python | en | ['en', 'error', 'th'] | False |
query_nlp_trial_stats | (arch, dataset, reduction=None, include_intermediates=False) |
Query trial stats of NLP benchmark given conditions, including config(arch + dataset) and training results after 50 epoch.
Parameters
----------
arch : dict or None
If a dict, it is in the format that is described in
:class:`nni.nas.benchmark.nlp.NlpTrialConfig`. Only trial stats match... |
Query trial stats of NLP benchmark given conditions, including config(arch + dataset) and training results after 50 epoch. | def query_nlp_trial_stats(arch, dataset, reduction=None, include_intermediates=False):
"""
Query trial stats of NLP benchmark given conditions, including config(arch + dataset) and training results after 50 epoch.
Parameters
----------
arch : dict or None
If a dict, it is in the format that... | [
"def",
"query_nlp_trial_stats",
"(",
"arch",
",",
"dataset",
",",
"reduction",
"=",
"None",
",",
"include_intermediates",
"=",
"False",
")",
":",
"fields",
"=",
"[",
"]",
"if",
"reduction",
"==",
"'none'",
":",
"reduction",
"=",
"None",
"if",
"reduction",
... | [
6,
0
] | [
60,
38
] | python | en | ['en', 'error', 'th'] | False |
Debouncer.__init__ | (
self,
hass: HomeAssistant,
logger: Logger,
*,
cooldown: float,
immediate: bool,
function: Optional[Callable[..., Awaitable[Any]]] = None,
) | Initialize debounce.
immediate: indicate if the function needs to be called right away and
wait <cooldown> until executing next invocation.
function: optional and can be instantiated later.
| Initialize debounce. | def __init__(
self,
hass: HomeAssistant,
logger: Logger,
*,
cooldown: float,
immediate: bool,
function: Optional[Callable[..., Awaitable[Any]]] = None,
):
"""Initialize debounce.
immediate: indicate if the function needs to be called right awa... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"logger",
":",
"Logger",
",",
"*",
",",
"cooldown",
":",
"float",
",",
"immediate",
":",
"bool",
",",
"function",
":",
"Optional",
"[",
"Callable",
"[",
"...",
",",
"Awaitable",
"[... | [
11,
4
] | [
34,
86
] | python | en | ['es', 'nl', 'en'] | False |
Debouncer.function | (self) | Return the function being wrapped by the Debouncer. | Return the function being wrapped by the Debouncer. | def function(self) -> Optional[Callable[..., Awaitable[Any]]]:
"""Return the function being wrapped by the Debouncer."""
return self._function | [
"def",
"function",
"(",
"self",
")",
"->",
"Optional",
"[",
"Callable",
"[",
"...",
",",
"Awaitable",
"[",
"Any",
"]",
"]",
"]",
":",
"return",
"self",
".",
"_function"
] | [
37,
4
] | [
39,
29
] | python | en | ['en', 'en', 'en'] | True |
Debouncer.function | (self, function: Callable[..., Awaitable[Any]]) | Update the function being wrapped by the Debouncer. | Update the function being wrapped by the Debouncer. | def function(self, function: Callable[..., Awaitable[Any]]) -> None:
"""Update the function being wrapped by the Debouncer."""
self._function = function
if self._job is None or function != self._job.target:
self._job = HassJob(function) | [
"def",
"function",
"(",
"self",
",",
"function",
":",
"Callable",
"[",
"...",
",",
"Awaitable",
"[",
"Any",
"]",
"]",
")",
"->",
"None",
":",
"self",
".",
"_function",
"=",
"function",
"if",
"self",
".",
"_job",
"is",
"None",
"or",
"function",
"!=",
... | [
42,
4
] | [
46,
41
] | python | en | ['en', 'en', 'en'] | True |
Debouncer.async_call | (self) | Call the function. | Call the function. | async def async_call(self) -> None:
"""Call the function."""
assert self.function is not None
if self._timer_task:
if not self._execute_at_end_of_timer:
self._execute_at_end_of_timer = True
return
# Locked means a call is in progress. Any call i... | [
"async",
"def",
"async_call",
"(",
"self",
")",
"->",
"None",
":",
"assert",
"self",
".",
"function",
"is",
"not",
"None",
"if",
"self",
".",
"_timer_task",
":",
"if",
"not",
"self",
".",
"_execute_at_end_of_timer",
":",
"self",
".",
"_execute_at_end_of_time... | [
48,
4
] | [
74,
34
] | python | en | ['en', 'en', 'en'] | True |
Debouncer._handle_timer_finish | (self) | Handle a finished timer. | Handle a finished timer. | async def _handle_timer_finish(self) -> None:
"""Handle a finished timer."""
assert self.function is not None
self._timer_task = None
if not self._execute_at_end_of_timer:
return
self._execute_at_end_of_timer = False
# Locked means a call is in progress. A... | [
"async",
"def",
"_handle_timer_finish",
"(",
"self",
")",
"->",
"None",
":",
"assert",
"self",
".",
"function",
"is",
"not",
"None",
"self",
".",
"_timer_task",
"=",
"None",
"if",
"not",
"self",
".",
"_execute_at_end_of_timer",
":",
"return",
"self",
".",
... | [
76,
4
] | [
101,
34
] | python | en | ['en', 'en', 'en'] | True |
Debouncer.async_cancel | (self) | Cancel any scheduled call. | Cancel any scheduled call. | def async_cancel(self) -> None:
"""Cancel any scheduled call."""
if self._timer_task:
self._timer_task.cancel()
self._timer_task = None
self._execute_at_end_of_timer = False | [
"def",
"async_cancel",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"_timer_task",
":",
"self",
".",
"_timer_task",
".",
"cancel",
"(",
")",
"self",
".",
"_timer_task",
"=",
"None",
"self",
".",
"_execute_at_end_of_timer",
"=",
"False"
] | [
104,
4
] | [
110,
45
] | python | en | ['en', 'en', 'en'] | True |
Debouncer._schedule_timer | (self) | Schedule a timer. | Schedule a timer. | def _schedule_timer(self) -> None:
"""Schedule a timer."""
self._timer_task = self.hass.loop.call_later(
self.cooldown,
lambda: self.hass.async_create_task(self._handle_timer_finish()),
) | [
"def",
"_schedule_timer",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_timer_task",
"=",
"self",
".",
"hass",
".",
"loop",
".",
"call_later",
"(",
"self",
".",
"cooldown",
",",
"lambda",
":",
"self",
".",
"hass",
".",
"async_create_task",
"(",
"... | [
113,
4
] | [
118,
9
] | python | en | ['en', 'de', 'en'] | True |
test_get_device_config | (hass, hass_client) | Test getting device config. | Test getting device config. | async def test_get_device_config(hass, hass_client):
"""Test getting device config."""
with patch.object(config, "SECTIONS", ["group"]):
await async_setup_component(hass, "config", {})
client = await hass_client()
def mock_read(path):
"""Mock reading data."""
return {"hello.bee... | [
"async",
"def",
"test_get_device_config",
"(",
"hass",
",",
"hass_client",
")",
":",
"with",
"patch",
".",
"object",
"(",
"config",
",",
"\"SECTIONS\"",
",",
"[",
"\"group\"",
"]",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"config\"",
"... | [
11,
0
] | [
28,
37
] | python | en | ['de', 'en', 'en'] | True |
test_update_device_config | (hass, hass_client) | Test updating device config. | Test updating device config. | async def test_update_device_config(hass, hass_client):
"""Test updating device config."""
with patch.object(config, "SECTIONS", ["group"]):
await async_setup_component(hass, "config", {})
client = await hass_client()
orig_data = {
"hello.beer": {"ignored": True},
"other.entity... | [
"async",
"def",
"test_update_device_config",
"(",
"hass",
",",
"hass_client",
")",
":",
"with",
"patch",
".",
"object",
"(",
"config",
",",
"\"SECTIONS\"",
",",
"[",
"\"group\"",
"]",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"config\"",
... | [
31,
0
] | [
74,
56
] | python | en | ['de', 'en', 'en'] | True |
test_update_device_config_invalid_key | (hass, hass_client) | Test updating device config. | Test updating device config. | async def test_update_device_config_invalid_key(hass, hass_client):
"""Test updating device config."""
with patch.object(config, "SECTIONS", ["group"]):
await async_setup_component(hass, "config", {})
client = await hass_client()
resp = await client.post(
"/api/config/group/config/not ... | [
"async",
"def",
"test_update_device_config_invalid_key",
"(",
"hass",
",",
"hass_client",
")",
":",
"with",
"patch",
".",
"object",
"(",
"config",
",",
"\"SECTIONS\"",
",",
"[",
"\"group\"",
"]",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\... | [
77,
0
] | [
88,
29
] | python | en | ['de', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.