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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Volumio.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
status = self._state.get("status", None)
if status == "pause":
return STATE_PAUSED
if status == "play":
return STATE_PLAYING
return STATE_IDLE | [
"def",
"state",
"(",
"self",
")",
":",
"status",
"=",
"self",
".",
"_state",
".",
"get",
"(",
"\"status\"",
",",
"None",
")",
"if",
"status",
"==",
"\"pause\"",
":",
"return",
"STATE_PAUSED",
"if",
"status",
"==",
"\"play\"",
":",
"return",
"STATE_PLAYIN... | [
118,
4
] | [
126,
25
] | python | en | ['en', 'en', 'en'] | True |
Volumio.media_title | (self) | Title of current playing media. | Title of current playing media. | def media_title(self):
"""Title of current playing media."""
return self._state.get("title", None) | [
"def",
"media_title",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state",
".",
"get",
"(",
"\"title\"",
",",
"None",
")"
] | [
129,
4
] | [
131,
45
] | python | en | ['en', 'en', 'en'] | True |
Volumio.media_artist | (self) | Artist of current playing media (Music track only). | Artist of current playing media (Music track only). | def media_artist(self):
"""Artist of current playing media (Music track only)."""
return self._state.get("artist", None) | [
"def",
"media_artist",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state",
".",
"get",
"(",
"\"artist\"",
",",
"None",
")"
] | [
134,
4
] | [
136,
46
] | python | en | ['en', 'en', 'en'] | True |
Volumio.media_album_name | (self) | Artist of current playing media (Music track only). | Artist of current playing media (Music track only). | def media_album_name(self):
"""Artist of current playing media (Music track only)."""
return self._state.get("album", None) | [
"def",
"media_album_name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state",
".",
"get",
"(",
"\"album\"",
",",
"None",
")"
] | [
139,
4
] | [
141,
45
] | python | en | ['en', 'en', 'en'] | True |
Volumio.media_image_url | (self) | Image url of current playing media. | Image url of current playing media. | def media_image_url(self):
"""Image url of current playing media."""
url = self._state.get("albumart", None)
return self._volumio.canonic_url(url) | [
"def",
"media_image_url",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_state",
".",
"get",
"(",
"\"albumart\"",
",",
"None",
")",
"return",
"self",
".",
"_volumio",
".",
"canonic_url",
"(",
"url",
")"
] | [
144,
4
] | [
147,
45
] | python | en | ['en', 'en', 'en'] | True |
Volumio.media_seek_position | (self) | Time in seconds of current seek position. | Time in seconds of current seek position. | def media_seek_position(self):
"""Time in seconds of current seek position."""
return self._state.get("seek", None) | [
"def",
"media_seek_position",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state",
".",
"get",
"(",
"\"seek\"",
",",
"None",
")"
] | [
150,
4
] | [
152,
44
] | python | en | ['en', 'en', 'en'] | True |
Volumio.media_duration | (self) | Time in seconds of current song duration. | Time in seconds of current song duration. | def media_duration(self):
"""Time in seconds of current song duration."""
return self._state.get("duration", None) | [
"def",
"media_duration",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state",
".",
"get",
"(",
"\"duration\"",
",",
"None",
")"
] | [
155,
4
] | [
157,
48
] | python | en | ['en', 'en', 'en'] | True |
Volumio.volume_level | (self) | Volume level of the media player (0..1). | Volume level of the media player (0..1). | def volume_level(self):
"""Volume level of the media player (0..1)."""
volume = self._state.get("volume", None)
if volume is not None and volume != "":
volume = int(volume) / 100
return volume | [
"def",
"volume_level",
"(",
"self",
")",
":",
"volume",
"=",
"self",
".",
"_state",
".",
"get",
"(",
"\"volume\"",
",",
"None",
")",
"if",
"volume",
"is",
"not",
"None",
"and",
"volume",
"!=",
"\"\"",
":",
"volume",
"=",
"int",
"(",
"volume",
")",
... | [
160,
4
] | [
165,
21
] | python | en | ['en', 'en', 'en'] | True |
Volumio.is_volume_muted | (self) | Boolean if volume is currently muted. | Boolean if volume is currently muted. | def is_volume_muted(self):
"""Boolean if volume is currently muted."""
return self._state.get("mute", None) | [
"def",
"is_volume_muted",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state",
".",
"get",
"(",
"\"mute\"",
",",
"None",
")"
] | [
168,
4
] | [
170,
44
] | python | en | ['en', 'en', 'en'] | True |
Volumio.shuffle | (self) | Boolean if shuffle is enabled. | Boolean if shuffle is enabled. | def shuffle(self):
"""Boolean if shuffle is enabled."""
return self._state.get("random", False) | [
"def",
"shuffle",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state",
".",
"get",
"(",
"\"random\"",
",",
"False",
")"
] | [
173,
4
] | [
175,
47
] | python | en | ['en', 'en', 'en'] | True |
Volumio.source_list | (self) | Return the list of available input sources. | Return the list of available input sources. | def source_list(self):
"""Return the list of available input sources."""
return self._playlists | [
"def",
"source_list",
"(",
"self",
")",
":",
"return",
"self",
".",
"_playlists"
] | [
178,
4
] | [
180,
30
] | python | en | ['en', 'en', 'en'] | True |
Volumio.source | (self) | Name of the current input source. | Name of the current input source. | def source(self):
"""Name of the current input source."""
return self._currentplaylist | [
"def",
"source",
"(",
"self",
")",
":",
"return",
"self",
".",
"_currentplaylist"
] | [
183,
4
] | [
185,
36
] | python | en | ['en', 'en', 'en'] | True |
Volumio.supported_features | (self) | Flag of media commands that are supported. | Flag of media commands that are supported. | def supported_features(self):
"""Flag of media commands that are supported."""
return SUPPORT_VOLUMIO | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_VOLUMIO"
] | [
188,
4
] | [
190,
30
] | python | en | ['en', 'en', 'en'] | True |
Volumio.async_media_next_track | (self) | Send media_next command to media player. | Send media_next command to media player. | async def async_media_next_track(self):
"""Send media_next command to media player."""
await self._volumio.next() | [
"async",
"def",
"async_media_next_track",
"(",
"self",
")",
":",
"await",
"self",
".",
"_volumio",
".",
"next",
"(",
")"
] | [
192,
4
] | [
194,
34
] | python | en | ['en', 'en', 'en'] | True |
Volumio.async_media_previous_track | (self) | Send media_previous command to media player. | Send media_previous command to media player. | async def async_media_previous_track(self):
"""Send media_previous command to media player."""
await self._volumio.previous() | [
"async",
"def",
"async_media_previous_track",
"(",
"self",
")",
":",
"await",
"self",
".",
"_volumio",
".",
"previous",
"(",
")"
] | [
196,
4
] | [
198,
38
] | python | en | ['en', 'en', 'en'] | True |
Volumio.async_media_play | (self) | Send media_play command to media player. | Send media_play command to media player. | async def async_media_play(self):
"""Send media_play command to media player."""
await self._volumio.play() | [
"async",
"def",
"async_media_play",
"(",
"self",
")",
":",
"await",
"self",
".",
"_volumio",
".",
"play",
"(",
")"
] | [
200,
4
] | [
202,
34
] | python | en | ['en', 'en', 'en'] | True |
Volumio.async_media_pause | (self) | Send media_pause command to media player. | Send media_pause command to media player. | async def async_media_pause(self):
"""Send media_pause command to media player."""
if self._state["trackType"] == "webradio":
await self._volumio.stop()
else:
await self._volumio.pause() | [
"async",
"def",
"async_media_pause",
"(",
"self",
")",
":",
"if",
"self",
".",
"_state",
"[",
"\"trackType\"",
"]",
"==",
"\"webradio\"",
":",
"await",
"self",
".",
"_volumio",
".",
"stop",
"(",
")",
"else",
":",
"await",
"self",
".",
"_volumio",
".",
... | [
204,
4
] | [
209,
39
] | python | en | ['en', 'en', 'en'] | True |
Volumio.async_media_stop | (self) | Send media_stop command to media player. | Send media_stop command to media player. | async def async_media_stop(self):
"""Send media_stop command to media player."""
await self._volumio.stop() | [
"async",
"def",
"async_media_stop",
"(",
"self",
")",
":",
"await",
"self",
".",
"_volumio",
".",
"stop",
"(",
")"
] | [
211,
4
] | [
213,
34
] | python | en | ['en', 'en', 'en'] | True |
Volumio.async_set_volume_level | (self, volume) | Send volume_up command to media player. | Send volume_up command to media player. | async def async_set_volume_level(self, volume):
"""Send volume_up command to media player."""
await self._volumio.set_volume_level(int(volume * 100)) | [
"async",
"def",
"async_set_volume_level",
"(",
"self",
",",
"volume",
")",
":",
"await",
"self",
".",
"_volumio",
".",
"set_volume_level",
"(",
"int",
"(",
"volume",
"*",
"100",
")",
")"
] | [
215,
4
] | [
217,
63
] | python | en | ['en', 'en', 'en'] | True |
Volumio.async_volume_up | (self) | Service to send the Volumio the command for volume up. | Service to send the Volumio the command for volume up. | async def async_volume_up(self):
"""Service to send the Volumio the command for volume up."""
await self._volumio.volume_up() | [
"async",
"def",
"async_volume_up",
"(",
"self",
")",
":",
"await",
"self",
".",
"_volumio",
".",
"volume_up",
"(",
")"
] | [
219,
4
] | [
221,
39
] | python | en | ['en', 'en', 'en'] | True |
Volumio.async_volume_down | (self) | Service to send the Volumio the command for volume down. | Service to send the Volumio the command for volume down. | async def async_volume_down(self):
"""Service to send the Volumio the command for volume down."""
await self._volumio.volume_down() | [
"async",
"def",
"async_volume_down",
"(",
"self",
")",
":",
"await",
"self",
".",
"_volumio",
".",
"volume_down",
"(",
")"
] | [
223,
4
] | [
225,
41
] | python | en | ['en', 'en', 'en'] | True |
Volumio.async_mute_volume | (self, mute) | Send mute command to media player. | Send mute command to media player. | async def async_mute_volume(self, mute):
"""Send mute command to media player."""
if mute:
await self._volumio.mute()
else:
await self._volumio.unmute() | [
"async",
"def",
"async_mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"if",
"mute",
":",
"await",
"self",
".",
"_volumio",
".",
"mute",
"(",
")",
"else",
":",
"await",
"self",
".",
"_volumio",
".",
"unmute",
"(",
")"
] | [
227,
4
] | [
232,
40
] | python | en | ['en', 'en', 'en'] | True |
Volumio.async_set_shuffle | (self, shuffle) | Enable/disable shuffle mode. | Enable/disable shuffle mode. | async def async_set_shuffle(self, shuffle):
"""Enable/disable shuffle mode."""
await self._volumio.set_shuffle(shuffle) | [
"async",
"def",
"async_set_shuffle",
"(",
"self",
",",
"shuffle",
")",
":",
"await",
"self",
".",
"_volumio",
".",
"set_shuffle",
"(",
"shuffle",
")"
] | [
234,
4
] | [
236,
48
] | python | en | ['en', 'st', 'en'] | True |
Volumio.async_select_source | (self, source) | Choose an available playlist and play it. | Choose an available playlist and play it. | async def async_select_source(self, source):
"""Choose an available playlist and play it."""
await self._volumio.play_playlist(source)
self._currentplaylist = source | [
"async",
"def",
"async_select_source",
"(",
"self",
",",
"source",
")",
":",
"await",
"self",
".",
"_volumio",
".",
"play_playlist",
"(",
"source",
")",
"self",
".",
"_currentplaylist",
"=",
"source"
] | [
238,
4
] | [
241,
38
] | python | en | ['en', 'en', 'en'] | True |
Volumio.async_clear_playlist | (self) | Clear players playlist. | Clear players playlist. | async def async_clear_playlist(self):
"""Clear players playlist."""
await self._volumio.clear_playlist()
self._currentplaylist = None | [
"async",
"def",
"async_clear_playlist",
"(",
"self",
")",
":",
"await",
"self",
".",
"_volumio",
".",
"clear_playlist",
"(",
")",
"self",
".",
"_currentplaylist",
"=",
"None"
] | [
243,
4
] | [
246,
36
] | python | en | ['fr', 'en', 'en'] | True |
Volumio._async_update_playlists | (self, **kwargs) | Update available Volumio playlists. | Update available Volumio playlists. | async def _async_update_playlists(self, **kwargs):
"""Update available Volumio playlists."""
self._playlists = await self._volumio.get_playlists() | [
"async",
"def",
"_async_update_playlists",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_playlists",
"=",
"await",
"self",
".",
"_volumio",
".",
"get_playlists",
"(",
")"
] | [
249,
4
] | [
251,
61
] | python | en | ['it', 'en', 'en'] | True |
Volumio.async_play_media | (self, media_type, media_id, **kwargs) | Send the play_media command to the media player. | Send the play_media command to the media player. | async def async_play_media(self, media_type, media_id, **kwargs):
"""Send the play_media command to the media player."""
await self._volumio.replace_and_play(json.loads(media_id)) | [
"async",
"def",
"async_play_media",
"(",
"self",
",",
"media_type",
",",
"media_id",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_volumio",
".",
"replace_and_play",
"(",
"json",
".",
"loads",
"(",
"media_id",
")",
")"
] | [
253,
4
] | [
255,
66
] | python | en | ['en', 'en', 'en'] | True |
Volumio.async_browse_media | (self, media_content_type=None, media_content_id=None) | Implement the websocket media browsing helper. | Implement the websocket media browsing helper. | async def async_browse_media(self, media_content_type=None, media_content_id=None):
"""Implement the websocket media browsing helper."""
if media_content_type in [None, "library"]:
return await browse_top_level(self._volumio)
return await browse_node(self._volumio, media_content_typ... | [
"async",
"def",
"async_browse_media",
"(",
"self",
",",
"media_content_type",
"=",
"None",
",",
"media_content_id",
"=",
"None",
")",
":",
"if",
"media_content_type",
"in",
"[",
"None",
",",
"\"library\"",
"]",
":",
"return",
"await",
"browse_top_level",
"(",
... | [
257,
4
] | [
262,
85
] | python | en | ['en', 'af', '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... | [
44,
0
] | [
54,
16
] | python | en | ['en', 'error', 'th'] | False |
text_standardize | (text) |
fixes some issues the spacy tokenizer had on books corpus also does some whitespace standardization
|
fixes some issues the spacy tokenizer had on books corpus also does some whitespace standardization
| def text_standardize(text):
"""
fixes some issues the spacy tokenizer had on books corpus also does some whitespace standardization
"""
text = text.replace("—", "-")
text = text.replace("–", "-")
text = text.replace("―", "-")
text = text.replace("…", "...")
text = text.replace("´", "'")
... | [
"def",
"text_standardize",
"(",
"text",
")",
":",
"text",
"=",
"text",
".",
"replace",
"(",
"\"—\", ",
"\"",
"\")",
"",
"text",
"=",
"text",
".",
"replace",
"(",
"\"–\", ",
"\"",
"\")",
"",
"text",
"=",
"text",
".",
"replace",
"(",
"\"―\", ",
"\"",
... | [
57,
0
] | [
69,
23
] | python | en | ['en', 'error', 'th'] | False |
OpenAIGPTTokenizer._tokenize | (self, text) | Tokenize a string. | Tokenize a string. | def _tokenize(self, text):
""" Tokenize a string. """
split_tokens = []
if self.fix_text is None:
# Using BERT's BasicTokenizer
text = self.nlp.tokenize(text)
for token in text:
split_tokens.extend([t for t in self.bpe(token).split(" ")])
... | [
"def",
"_tokenize",
"(",
"self",
",",
"text",
")",
":",
"split_tokens",
"=",
"[",
"]",
"if",
"self",
".",
"fix_text",
"is",
"None",
":",
"# Using BERT's BasicTokenizer",
"text",
"=",
"self",
".",
"nlp",
".",
"tokenize",
"(",
"text",
")",
"for",
"token",
... | [
177,
4
] | [
190,
27
] | python | en | ['en', 'gl', 'en'] | True |
OpenAIGPTTokenizer._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",
")",
")"
] | [
192,
4
] | [
194,
72
] | python | en | ['en', 'en', 'en'] | True |
OpenAIGPTTokenizer._convert_id_to_token | (self, index) | Converts an id in a token (BPE) using the vocab. | Converts an id in a token (BPE) using the vocab. | def _convert_id_to_token(self, index):
"""Converts an id in a token (BPE) 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",
")"
] | [
196,
4
] | [
198,
54
] | python | en | ['en', 'en', 'en'] | True |
OpenAIGPTTokenizer.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"
] | [
200,
4
] | [
203,
25
] | python | en | ['en', 'en', 'en'] | True |
async_validate_config_item | (hass, config, full_config=None) | Validate config item. | Validate config item. | async def async_validate_config_item(hass, config, full_config=None):
"""Validate config item."""
if blueprint.is_blueprint_instance_config(config):
blueprints = async_get_blueprints(hass)
return await blueprints.async_inputs_from_config(config)
config = PLATFORM_SCHEMA(config)
config[... | [
"async",
"def",
"async_validate_config_item",
"(",
"hass",
",",
"config",
",",
"full_config",
"=",
"None",
")",
":",
"if",
"blueprint",
".",
"is_blueprint_instance_config",
"(",
"config",
")",
":",
"blueprints",
"=",
"async_get_blueprints",
"(",
"hass",
")",
"re... | [
53,
0
] | [
77,
17
] | python | en | ['en', 'la', 'en'] | True |
_try_async_validate_config_item | (hass, config, full_config=None) | Validate config item. | Validate config item. | async def _try_async_validate_config_item(hass, config, full_config=None):
"""Validate config item."""
try:
config = await async_validate_config_item(hass, config, full_config)
except (
vol.Invalid,
HomeAssistantError,
IntegrationNotFound,
InvalidDeviceAutomationConfi... | [
"async",
"def",
"_try_async_validate_config_item",
"(",
"hass",
",",
"config",
",",
"full_config",
"=",
"None",
")",
":",
"try",
":",
"config",
"=",
"await",
"async_validate_config_item",
"(",
"hass",
",",
"config",
",",
"full_config",
")",
"except",
"(",
"vol... | [
80,
0
] | [
93,
17
] | python | en | ['en', 'la', 'en'] | True |
async_validate_config | (hass, config) | Validate config. | Validate config. | async def async_validate_config(hass, config):
"""Validate config."""
automations = list(
filter(
lambda x: x is not None,
await asyncio.gather(
*(
_try_async_validate_config_item(hass, p_config, config)
for _, p_config in c... | [
"async",
"def",
"async_validate_config",
"(",
"hass",
",",
"config",
")",
":",
"automations",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"x",
":",
"x",
"is",
"not",
"None",
",",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"(",
"_try_async_validate_config_... | [
96,
0
] | [
115,
17
] | python | en | ['en', 'la', 'it'] | False |
_matching_fc | (tensor, name, size, nsteps, init_scale, init_bias, np_mask, is_act_model) |
Add fc op, and add mask op when not in action mode
|
Add fc op, and add mask op when not in action mode
| def _matching_fc(tensor, name, size, nsteps, init_scale, init_bias, np_mask, is_act_model):
"""
Add fc op, and add mask op when not in action mode
"""
if tensor.shape[-1] == size:
assert False
return tensor
else:
mask = tf.get_variable("act_mask", dtype=tf.float32, initialize... | [
"def",
"_matching_fc",
"(",
"tensor",
",",
"name",
",",
"size",
",",
"nsteps",
",",
"init_scale",
",",
"init_bias",
",",
"np_mask",
",",
"is_act_model",
")",
":",
"if",
"tensor",
".",
"shape",
"[",
"-",
"1",
"]",
"==",
"size",
":",
"assert",
"False",
... | [
165,
0
] | [
182,
40
] | python | en | ['en', 'error', 'th'] | False |
CategoricalPd.neglogp | (self, x) |
return tf.nn.sparse_softmax_cross_entropy_with_logits(logits=self.logits, labels=x)
Note: we can't use sparse_softmax_cross_entropy_with_logits because
the implementation does not allow second-order derivatives...
|
return tf.nn.sparse_softmax_cross_entropy_with_logits(logits=self.logits, labels=x)
Note: we can't use sparse_softmax_cross_entropy_with_logits because
the implementation does not allow second-order derivatives...
| def neglogp(self, x):
"""
return tf.nn.sparse_softmax_cross_entropy_with_logits(logits=self.logits, labels=x)
Note: we can't use sparse_softmax_cross_entropy_with_logits because
the implementation does not allow second-order derivatives...
"""
if x.dtype in {tf.uint... | [
"def",
"neglogp",
"(",
"self",
",",
"x",
")",
":",
"if",
"x",
".",
"dtype",
"in",
"{",
"tf",
".",
"uint8",
",",
"tf",
".",
"int32",
",",
"tf",
".",
"int64",
"}",
":",
"# one-hot encoding",
"x_shape_list",
"=",
"x",
".",
"shape",
".",
"as_list",
"... | [
80,
4
] | [
101,
21
] | python | en | ['en', 'error', 'th'] | False |
CategoricalPd.entropy | (self) | compute entropy | compute entropy | def entropy(self):
"""compute entropy"""
a0 = self.logits - tf.reduce_max(self.logits, axis=-1, keepdims=True)
ea0 = tf.exp(a0)
z0 = tf.reduce_sum(ea0, axis=-1, keepdims=True)
p0 = ea0 / z0
return tf.reduce_sum(p0 * (tf.log(z0) - a0), axis=-1) | [
"def",
"entropy",
"(",
"self",
")",
":",
"a0",
"=",
"self",
".",
"logits",
"-",
"tf",
".",
"reduce_max",
"(",
"self",
".",
"logits",
",",
"axis",
"=",
"-",
"1",
",",
"keepdims",
"=",
"True",
")",
"ea0",
"=",
"tf",
".",
"exp",
"(",
"a0",
")",
... | [
114,
4
] | [
120,
61
] | python | fr | ['fr', 'fr', 'it'] | False |
CategoricalPd.sample | (self) | sample from logits | sample from logits | def sample(self):
"""sample from logits"""
if not self.is_act_model:
re_res = tf.reshape(self.logits, [-1, self.nsteps, self.size])
masked_res = tf.math.add(re_res, self.mask_npinf)
re_masked_res = tf.reshape(masked_res, [-1, self.size])
u = tf.random_uni... | [
"def",
"sample",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_act_model",
":",
"re_res",
"=",
"tf",
".",
"reshape",
"(",
"self",
".",
"logits",
",",
"[",
"-",
"1",
",",
"self",
".",
"nsteps",
",",
"self",
".",
"size",
"]",
")",
"masked_re... | [
122,
4
] | [
133,
73
] | python | en | ['en', 'en', 'en'] | True |
CategoricalPdType.pdfromlatent | (self, latent_vector, init_scale=1.0, init_bias=0.0) | add fc and create CategoricalPd | add fc and create CategoricalPd | def pdfromlatent(self, latent_vector, init_scale=1.0, init_bias=0.0):
"""add fc and create CategoricalPd"""
pdparam, mask, mask_npinf = _matching_fc(latent_vector, 'pi', self.ncat, self.nsteps,
init_scale=init_scale, init_bias=init_bias,
... | [
"def",
"pdfromlatent",
"(",
"self",
",",
"latent_vector",
",",
"init_scale",
"=",
"1.0",
",",
"init_bias",
"=",
"0.0",
")",
":",
"pdparam",
",",
"mask",
",",
"mask_npinf",
"=",
"_matching_fc",
"(",
"latent_vector",
",",
"'pi'",
",",
"self",
".",
"ncat",
... | [
151,
4
] | [
156,
121
] | python | en | ['en', 'en', 'en'] | True |
FunnelTokenizer.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. A Funnel
Transformer sequence pair mask has the following format:
::
2 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_i... |
Create a mask from the two sequences passed to be used in a sequence-pair classification task. A Funnel
Transformer 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. A Funnel
Transformer sequence pair mask has the following... | [
"def",
"create_token_type_ids_from_sequences",
"(",
"self",
",",
"token_ids_0",
":",
"List",
"[",
"int",
"]",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"int",
"]",
":",
"sep",
"=",
"[",... | [
108,
4
] | [
136,
112
] | python | en | ['en', 'error', 'th'] | False |
TFElectraEmbeddings.call | (
self,
input_ids: tf.Tensor = None,
position_ids: tf.Tensor = None,
token_type_ids: tf.Tensor = None,
inputs_embeds: tf.Tensor = None,
training: bool = False,
) |
Applies embedding based on inputs tensor.
Returns:
final_embeddings (:obj:`tf.Tensor`): output embedding tensor.
|
Applies embedding based on inputs tensor. | def call(
self,
input_ids: tf.Tensor = None,
position_ids: tf.Tensor = None,
token_type_ids: tf.Tensor = None,
inputs_embeds: tf.Tensor = None,
training: bool = False,
) -> tf.Tensor:
"""
Applies embedding based on inputs tensor.
Returns:
... | [
"def",
"call",
"(",
"self",
",",
"input_ids",
":",
"tf",
".",
"Tensor",
"=",
"None",
",",
"position_ids",
":",
"tf",
".",
"Tensor",
"=",
"None",
",",
"token_type_ids",
":",
"tf",
".",
"Tensor",
"=",
"None",
",",
"inputs_embeds",
":",
"tf",
".",
"Tens... | [
392,
4
] | [
426,
31
] | python | en | ['en', 'error', 'th'] | False |
async_verify_local_connection | (hass: core.HomeAssistant, host: str) | Verify that a local connection works. | Verify that a local connection works. | async def async_verify_local_connection(hass: core.HomeAssistant, host: str):
"""Verify that a local connection works."""
websession = aiohttp_client.async_get_clientsession(hass)
api = WebAlmondAPI(AlmondLocalAuth(host, websession))
try:
with async_timeout.timeout(10):
await api.as... | [
"async",
"def",
"async_verify_local_connection",
"(",
"hass",
":",
"core",
".",
"HomeAssistant",
",",
"host",
":",
"str",
")",
":",
"websession",
"=",
"aiohttp_client",
".",
"async_get_clientsession",
"(",
"hass",
")",
"api",
"=",
"WebAlmondAPI",
"(",
"AlmondLoc... | [
16,
0
] | [
27,
20
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Travis CI sensor. | Set up the Travis CI sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Travis CI sensor."""
token = config.get(CONF_API_KEY)
repositories = config.get(CONF_REPOSITORY)
branch = config.get(CONF_BRANCH)
try:
travis = TravisPy.github_auth(token)
user = travis.user()
e... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"token",
"=",
"config",
".",
"get",
"(",
"CONF_API_KEY",
")",
"repositories",
"=",
"config",
".",
"get",
"(",
"CONF_REPOSITORY",
")",
"b... | [
56,
0
] | [
93,
15
] | python | en | ['en', 'bs', 'en'] | True |
TravisCISensor.__init__ | (self, data, repo_name, user, branch, sensor_type) | Initialize the sensor. | Initialize the sensor. | def __init__(self, data, repo_name, user, branch, sensor_type):
"""Initialize the sensor."""
self._build = None
self._sensor_type = sensor_type
self._data = data
self._repo_name = repo_name
self._user = user
self._branch = branch
self._state = None
... | [
"def",
"__init__",
"(",
"self",
",",
"data",
",",
"repo_name",
",",
"user",
",",
"branch",
",",
"sensor_type",
")",
":",
"self",
".",
"_build",
"=",
"None",
"self",
".",
"_sensor_type",
"=",
"sensor_type",
"self",
".",
"_data",
"=",
"data",
"self",
"."... | [
99,
4
] | [
108,
88
] | python | en | ['en', 'en', 'en'] | True |
TravisCISensor.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"
] | [
111,
4
] | [
113,
25
] | python | en | ['en', 'mi', 'en'] | True |
TravisCISensor.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 SENSOR_TYPES[self._sensor_type][1] | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"SENSOR_TYPES",
"[",
"self",
".",
"_sensor_type",
"]",
"[",
"1",
"]"
] | [
116,
4
] | [
118,
49
] | python | en | ['en', 'en', 'en'] | True |
TravisCISensor.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"
] | [
121,
4
] | [
123,
26
] | python | en | ['en', 'en', 'en'] | True |
TravisCISensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
attrs = {}
attrs[ATTR_ATTRIBUTION] = ATTRIBUTION
if self._build and self._state is not None:
if self._user and self._sensor_type == "state":
attrs["Owner Name"] = self._user.name
... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"{",
"}",
"attrs",
"[",
"ATTR_ATTRIBUTION",
"]",
"=",
"ATTRIBUTION",
"if",
"self",
".",
"_build",
"and",
"self",
".",
"_state",
"is",
"not",
"None",
":",
"if",
"self",
".",
"_user",
... | [
126,
4
] | [
142,
20
] | python | en | ['en', 'en', 'en'] | True |
TravisCISensor.icon | (self) | Return the icon to use in the frontend, if any. | Return the icon to use in the frontend, if any. | def icon(self):
"""Return the icon to use in the frontend, if any."""
return SENSOR_TYPES[self._sensor_type][2] | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"SENSOR_TYPES",
"[",
"self",
".",
"_sensor_type",
"]",
"[",
"2",
"]"
] | [
145,
4
] | [
147,
49
] | python | en | ['en', 'en', 'en'] | True |
TravisCISensor.update | (self) | Get the latest data and updates the states. | Get the latest data and updates the states. | def update(self):
"""Get the latest data and updates the states."""
_LOGGER.debug("Updating sensor %s", self._name)
repo = self._data.repo(self._repo_name)
self._build = self._data.build(repo.last_build_id)
if self._build:
if self._sensor_type == "state":
... | [
"def",
"update",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Updating sensor %s\"",
",",
"self",
".",
"_name",
")",
"repo",
"=",
"self",
".",
"_data",
".",
"repo",
"(",
"self",
".",
"_repo_name",
")",
"self",
".",
"_build",
"=",
"self",
"... | [
149,
4
] | [
163,
57
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Create the lights for the Ring devices. | Create the lights for the Ring devices. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Create the lights for the Ring devices."""
devices = hass.data[DOMAIN][config_entry.entry_id]["devices"]
lights = []
for device in devices["stickup_cams"]:
if device.has_capability("light"):
lights.append(RingL... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"devices",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"[",
"\"devices\"",
"]",
"lights",
"=",
"[",
"]"... | [
27,
0
] | [
37,
30
] | python | en | ['en', 'en', 'en'] | True |
RingLight.__init__ | (self, config_entry_id, device) | Initialize the light. | Initialize the light. | def __init__(self, config_entry_id, device):
"""Initialize the light."""
super().__init__(config_entry_id, device)
self._unique_id = device.id
self._light_on = device.lights == ON_STATE
self._no_updates_until = dt_util.utcnow() | [
"def",
"__init__",
"(",
"self",
",",
"config_entry_id",
",",
"device",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"config_entry_id",
",",
"device",
")",
"self",
".",
"_unique_id",
"=",
"device",
".",
"id",
"self",
".",
"_light_on",
"=",
"device",... | [
43,
4
] | [
48,
49
] | python | en | ['en', 'en', 'en'] | True |
RingLight._update_callback | (self) | Call update method. | Call update method. | def _update_callback(self):
"""Call update method."""
if self._no_updates_until > dt_util.utcnow():
return
self._light_on = self._device.lights == ON_STATE
self.async_write_ha_state() | [
"def",
"_update_callback",
"(",
"self",
")",
":",
"if",
"self",
".",
"_no_updates_until",
">",
"dt_util",
".",
"utcnow",
"(",
")",
":",
"return",
"self",
".",
"_light_on",
"=",
"self",
".",
"_device",
".",
"lights",
"==",
"ON_STATE",
"self",
".",
"async_... | [
51,
4
] | [
57,
35
] | python | en | ['en', 'sn', 'en'] | True |
RingLight.name | (self) | Name of the light. | Name of the light. | def name(self):
"""Name of the light."""
return f"{self._device.name} light" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self._device.name} light\""
] | [
60,
4
] | [
62,
43
] | python | en | ['en', 'en', 'en'] | True |
RingLight.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self):
"""Return a unique ID."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
65,
4
] | [
67,
30
] | python | ca | ['fr', 'ca', 'en'] | False |
RingLight.is_on | (self) | If the switch is currently on or off. | If the switch is currently on or off. | def is_on(self):
"""If the switch is currently on or off."""
return self._light_on | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_light_on"
] | [
70,
4
] | [
72,
29
] | python | en | ['en', 'en', 'en'] | True |
RingLight._set_light | (self, new_state) | Update light state, and causes Home Assistant to correctly update. | Update light state, and causes Home Assistant to correctly update. | def _set_light(self, new_state):
"""Update light state, and causes Home Assistant to correctly update."""
try:
self._device.lights = new_state
except requests.Timeout:
_LOGGER.error("Time out setting %s light to %s", self.entity_id, new_state)
return
... | [
"def",
"_set_light",
"(",
"self",
",",
"new_state",
")",
":",
"try",
":",
"self",
".",
"_device",
".",
"lights",
"=",
"new_state",
"except",
"requests",
".",
"Timeout",
":",
"_LOGGER",
".",
"error",
"(",
"\"Time out setting %s light to %s\"",
",",
"self",
".... | [
74,
4
] | [
84,
35
] | python | en | ['en', 'en', 'en'] | True |
RingLight.turn_on | (self, **kwargs) | Turn the light on for 30 seconds. | Turn the light on for 30 seconds. | def turn_on(self, **kwargs):
"""Turn the light on for 30 seconds."""
self._set_light(ON_STATE) | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_set_light",
"(",
"ON_STATE",
")"
] | [
86,
4
] | [
88,
33
] | python | en | ['en', 'en', 'en'] | True |
RingLight.turn_off | (self, **kwargs) | Turn the light off. | Turn the light off. | def turn_off(self, **kwargs):
"""Turn the light off."""
self._set_light(OFF_STATE) | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_set_light",
"(",
"OFF_STATE",
")"
] | [
90,
4
] | [
92,
34
] | python | en | ['en', 'zh', 'en'] | True |
async_setup_entry | (
hass: HomeAssistantType,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) | Set up Sonarr sensors based on a config entry. | Set up Sonarr sensors based on a config entry. | async def async_setup_entry(
hass: HomeAssistantType,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) -> None:
"""Set up Sonarr sensors based on a config entry."""
options = entry.options
sonarr = hass.data[DOMAIN][entry.entry_id][DATA_SONARR]
entities = [
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"Callable",
"[",
"[",
"List",
"[",
"Entity",
"]",
",",
"bool",
"]",
",",
"None",
"]",
",",
")",
"->",
"None",
":... | [
19,
0
] | [
39,
38
] | python | en | ['en', 'da', 'en'] | True |
sonarr_exception_handler | (func) | Decorate Sonarr calls to handle Sonarr exceptions.
A decorator that wraps the passed in function, catches Sonarr errors,
and handles the availability of the entity.
| Decorate Sonarr calls to handle Sonarr exceptions. | def sonarr_exception_handler(func):
"""Decorate Sonarr calls to handle Sonarr exceptions.
A decorator that wraps the passed in function, catches Sonarr errors,
and handles the availability of the entity.
"""
async def handler(self, *args, **kwargs):
try:
await func(self, *args,... | [
"def",
"sonarr_exception_handler",
"(",
"func",
")",
":",
"async",
"def",
"handler",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"await",
"func",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",... | [
42,
0
] | [
62,
18
] | python | en | ['en', 'en', 'en'] | True |
SonarrSensor.__init__ | (
self,
*,
sonarr: Sonarr,
entry_id: str,
enabled_default: bool = True,
icon: str,
key: str,
name: str,
unit_of_measurement: Optional[str] = None,
) | Initialize Sonarr sensor. | Initialize Sonarr sensor. | def __init__(
self,
*,
sonarr: Sonarr,
entry_id: str,
enabled_default: bool = True,
icon: str,
key: str,
name: str,
unit_of_measurement: Optional[str] = None,
) -> None:
"""Initialize Sonarr sensor."""
self._unit_of_measurement ... | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"sonarr",
":",
"Sonarr",
",",
"entry_id",
":",
"str",
",",
"enabled_default",
":",
"bool",
"=",
"True",
",",
"icon",
":",
"str",
",",
"key",
":",
"str",
",",
"name",
":",
"str",
",",
"unit_of_measurement... | [
68,
4
] | [
92,
9
] | python | en | ['en', 'pt', 'en'] | True |
SonarrSensor.unique_id | (self) | Return the unique ID for this sensor. | Return the unique ID for this sensor. | def unique_id(self) -> str:
"""Return the unique ID for this sensor."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_unique_id"
] | [
95,
4
] | [
97,
30
] | python | en | ['en', 'la', 'en'] | True |
SonarrSensor.available | (self) | Return sensor availability. | Return sensor availability. | def available(self) -> bool:
"""Return sensor availability."""
return self.last_update_success | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"last_update_success"
] | [
100,
4
] | [
102,
39
] | python | en | ['fr', 'ga', 'en'] | False |
SonarrSensor.unit_of_measurement | (self) | Return the unit this state is expressed in. | Return the unit this state is expressed in. | def unit_of_measurement(self) -> str:
"""Return the unit this state is expressed in."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
105,
4
] | [
107,
40
] | python | en | ['en', 'en', 'en'] | True |
SonarrCommandsSensor.__init__ | (self, sonarr: Sonarr, entry_id: str) | Initialize Sonarr Commands sensor. | Initialize Sonarr Commands sensor. | def __init__(self, sonarr: Sonarr, entry_id: str) -> None:
"""Initialize Sonarr Commands sensor."""
self._commands = []
super().__init__(
sonarr=sonarr,
entry_id=entry_id,
icon="mdi:code-braces",
key="commands",
name=f"{sonarr.app.info... | [
"def",
"__init__",
"(",
"self",
",",
"sonarr",
":",
"Sonarr",
",",
"entry_id",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"_commands",
"=",
"[",
"]",
"super",
"(",
")",
".",
"__init__",
"(",
"sonarr",
"=",
"sonarr",
",",
"entry_id",
"=",
"ent... | [
113,
4
] | [
125,
9
] | python | en | ['es', 'fr', 'en'] | False |
SonarrCommandsSensor.async_update | (self) | Update entity. | Update entity. | async def async_update(self) -> None:
"""Update entity."""
self._commands = await self.sonarr.commands() | [
"async",
"def",
"async_update",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_commands",
"=",
"await",
"self",
".",
"sonarr",
".",
"commands",
"(",
")"
] | [
128,
4
] | [
130,
53
] | python | en | ['es', 'en', 'en'] | False |
SonarrCommandsSensor.device_state_attributes | (self) | Return the state attributes of the entity. | Return the state attributes of the entity. | def device_state_attributes(self) -> Optional[Dict[str, Any]]:
"""Return the state attributes of the entity."""
attrs = {}
for command in self._commands:
attrs[command.name] = command.state
return attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"attrs",
"=",
"{",
"}",
"for",
"command",
"in",
"self",
".",
"_commands",
":",
"attrs",
"[",
"command",
".",
"name",
"]",
"=",
... | [
133,
4
] | [
140,
20
] | python | en | ['en', 'en', 'en'] | True |
SonarrCommandsSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self) -> int:
"""Return the state of the sensor."""
return len(self._commands) | [
"def",
"state",
"(",
"self",
")",
"->",
"int",
":",
"return",
"len",
"(",
"self",
".",
"_commands",
")"
] | [
143,
4
] | [
145,
34
] | python | en | ['en', 'en', 'en'] | True |
SonarrDiskspaceSensor.__init__ | (self, sonarr: Sonarr, entry_id: str) | Initialize Sonarr Disk Space sensor. | Initialize Sonarr Disk Space sensor. | def __init__(self, sonarr: Sonarr, entry_id: str) -> None:
"""Initialize Sonarr Disk Space sensor."""
self._disks = []
self._total_free = 0
super().__init__(
sonarr=sonarr,
entry_id=entry_id,
icon="mdi:harddisk",
key="diskspace",
... | [
"def",
"__init__",
"(",
"self",
",",
"sonarr",
":",
"Sonarr",
",",
"entry_id",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"_disks",
"=",
"[",
"]",
"self",
".",
"_total_free",
"=",
"0",
"super",
"(",
")",
".",
"__init__",
"(",
"sonarr",
"=",
... | [
151,
4
] | [
164,
9
] | python | da | ['nn', 'da', 'en'] | False |
SonarrDiskspaceSensor.async_update | (self) | Update entity. | Update entity. | async def async_update(self) -> None:
"""Update entity."""
app = await self.sonarr.update()
self._disks = app.disks
self._total_free = sum([disk.free for disk in self._disks]) | [
"async",
"def",
"async_update",
"(",
"self",
")",
"->",
"None",
":",
"app",
"=",
"await",
"self",
".",
"sonarr",
".",
"update",
"(",
")",
"self",
".",
"_disks",
"=",
"app",
".",
"disks",
"self",
".",
"_total_free",
"=",
"sum",
"(",
"[",
"disk",
"."... | [
167,
4
] | [
171,
67
] | python | en | ['es', 'en', 'en'] | False |
SonarrDiskspaceSensor.device_state_attributes | (self) | Return the state attributes of the entity. | Return the state attributes of the entity. | def device_state_attributes(self) -> Optional[Dict[str, Any]]:
"""Return the state attributes of the entity."""
attrs = {}
for disk in self._disks:
free = disk.free / 1024 ** 3
total = disk.total / 1024 ** 3
usage = free / total * 100
attrs[
... | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"attrs",
"=",
"{",
"}",
"for",
"disk",
"in",
"self",
".",
"_disks",
":",
"free",
"=",
"disk",
".",
"free",
"/",
"1024",
"**",
... | [
174,
4
] | [
187,
20
] | python | en | ['en', 'en', 'en'] | True |
SonarrDiskspaceSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self) -> str:
"""Return the state of the sensor."""
free = self._total_free / 1024 ** 3
return f"{free:.2f}" | [
"def",
"state",
"(",
"self",
")",
"->",
"str",
":",
"free",
"=",
"self",
".",
"_total_free",
"/",
"1024",
"**",
"3",
"return",
"f\"{free:.2f}\""
] | [
190,
4
] | [
193,
28
] | python | en | ['en', 'en', 'en'] | True |
SonarrQueueSensor.__init__ | (self, sonarr: Sonarr, entry_id: str) | Initialize Sonarr Queue sensor. | Initialize Sonarr Queue sensor. | def __init__(self, sonarr: Sonarr, entry_id: str) -> None:
"""Initialize Sonarr Queue sensor."""
self._queue = []
super().__init__(
sonarr=sonarr,
entry_id=entry_id,
icon="mdi:download",
key="queue",
name=f"{sonarr.app.info.app_name} Q... | [
"def",
"__init__",
"(",
"self",
",",
"sonarr",
":",
"Sonarr",
",",
"entry_id",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"_queue",
"=",
"[",
"]",
"super",
"(",
")",
".",
"__init__",
"(",
"sonarr",
"=",
"sonarr",
",",
"entry_id",
"=",
"entry_... | [
199,
4
] | [
211,
9
] | python | pt | ['es', 'pt', 'pt'] | True |
SonarrQueueSensor.async_update | (self) | Update entity. | Update entity. | async def async_update(self) -> None:
"""Update entity."""
self._queue = await self.sonarr.queue() | [
"async",
"def",
"async_update",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_queue",
"=",
"await",
"self",
".",
"sonarr",
".",
"queue",
"(",
")"
] | [
214,
4
] | [
216,
47
] | python | en | ['es', 'en', 'en'] | False |
SonarrQueueSensor.device_state_attributes | (self) | Return the state attributes of the entity. | Return the state attributes of the entity. | def device_state_attributes(self) -> Optional[Dict[str, Any]]:
"""Return the state attributes of the entity."""
attrs = {}
for item in self._queue:
remaining = 1 if item.size == 0 else item.size_remaining / item.size
remaining_pct = 100 * (1 - remaining)
name... | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"attrs",
"=",
"{",
"}",
"for",
"item",
"in",
"self",
".",
"_queue",
":",
"remaining",
"=",
"1",
"if",
"item",
".",
"size",
"==... | [
219,
4
] | [
229,
20
] | python | en | ['en', 'en', 'en'] | True |
SonarrQueueSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self) -> int:
"""Return the state of the sensor."""
return len(self._queue) | [
"def",
"state",
"(",
"self",
")",
"->",
"int",
":",
"return",
"len",
"(",
"self",
".",
"_queue",
")"
] | [
232,
4
] | [
234,
31
] | python | en | ['en', 'en', 'en'] | True |
SonarrSeriesSensor.__init__ | (self, sonarr: Sonarr, entry_id: str) | Initialize Sonarr Series sensor. | Initialize Sonarr Series sensor. | def __init__(self, sonarr: Sonarr, entry_id: str) -> None:
"""Initialize Sonarr Series sensor."""
self._items = []
super().__init__(
sonarr=sonarr,
entry_id=entry_id,
icon="mdi:television",
key="series",
name=f"{sonarr.app.info.app_nam... | [
"def",
"__init__",
"(",
"self",
",",
"sonarr",
":",
"Sonarr",
",",
"entry_id",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"_items",
"=",
"[",
"]",
"super",
"(",
")",
".",
"__init__",
"(",
"sonarr",
"=",
"sonarr",
",",
"entry_id",
"=",
"entry_... | [
240,
4
] | [
252,
9
] | python | en | ['es', 'pt', 'en'] | False |
SonarrSeriesSensor.async_update | (self) | Update entity. | Update entity. | async def async_update(self) -> None:
"""Update entity."""
self._items = await self.sonarr.series() | [
"async",
"def",
"async_update",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_items",
"=",
"await",
"self",
".",
"sonarr",
".",
"series",
"(",
")"
] | [
255,
4
] | [
257,
48
] | python | en | ['es', 'en', 'en'] | False |
SonarrSeriesSensor.device_state_attributes | (self) | Return the state attributes of the entity. | Return the state attributes of the entity. | def device_state_attributes(self) -> Optional[Dict[str, Any]]:
"""Return the state attributes of the entity."""
attrs = {}
for item in self._items:
attrs[item.series.title] = f"{item.downloaded}/{item.episodes} Episodes"
return attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"attrs",
"=",
"{",
"}",
"for",
"item",
"in",
"self",
".",
"_items",
":",
"attrs",
"[",
"item",
".",
"series",
".",
"title",
"]... | [
260,
4
] | [
267,
20
] | python | en | ['en', 'en', 'en'] | True |
SonarrSeriesSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self) -> int:
"""Return the state of the sensor."""
return len(self._items) | [
"def",
"state",
"(",
"self",
")",
"->",
"int",
":",
"return",
"len",
"(",
"self",
".",
"_items",
")"
] | [
270,
4
] | [
272,
31
] | python | en | ['en', 'en', 'en'] | True |
SonarrUpcomingSensor.__init__ | (self, sonarr: Sonarr, entry_id: str, days: int = 1) | Initialize Sonarr Upcoming sensor. | Initialize Sonarr Upcoming sensor. | def __init__(self, sonarr: Sonarr, entry_id: str, days: int = 1) -> None:
"""Initialize Sonarr Upcoming sensor."""
self._days = days
self._upcoming = []
super().__init__(
sonarr=sonarr,
entry_id=entry_id,
icon="mdi:television",
key="upcomi... | [
"def",
"__init__",
"(",
"self",
",",
"sonarr",
":",
"Sonarr",
",",
"entry_id",
":",
"str",
",",
"days",
":",
"int",
"=",
"1",
")",
"->",
"None",
":",
"self",
".",
"_days",
"=",
"days",
"self",
".",
"_upcoming",
"=",
"[",
"]",
"super",
"(",
")",
... | [
278,
4
] | [
290,
9
] | python | en | ['en', 'pt', 'en'] | True |
SonarrUpcomingSensor.async_update | (self) | Update entity. | Update entity. | async def async_update(self) -> None:
"""Update entity."""
local = dt_util.start_of_local_day().replace(microsecond=0)
start = dt_util.as_utc(local)
end = start + timedelta(days=self._days)
self._upcoming = await self.sonarr.calendar(
start=start.isoformat(), end=end.... | [
"async",
"def",
"async_update",
"(",
"self",
")",
"->",
"None",
":",
"local",
"=",
"dt_util",
".",
"start_of_local_day",
"(",
")",
".",
"replace",
"(",
"microsecond",
"=",
"0",
")",
"start",
"=",
"dt_util",
".",
"as_utc",
"(",
"local",
")",
"end",
"=",... | [
293,
4
] | [
300,
9
] | python | en | ['es', 'en', 'en'] | False |
SonarrUpcomingSensor.device_state_attributes | (self) | Return the state attributes of the entity. | Return the state attributes of the entity. | def device_state_attributes(self) -> Optional[Dict[str, Any]]:
"""Return the state attributes of the entity."""
attrs = {}
for episode in self._upcoming:
attrs[episode.series.title] = episode.identifier
return attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"attrs",
"=",
"{",
"}",
"for",
"episode",
"in",
"self",
".",
"_upcoming",
":",
"attrs",
"[",
"episode",
".",
"series",
".",
"tit... | [
303,
4
] | [
310,
20
] | python | en | ['en', 'en', 'en'] | True |
SonarrUpcomingSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self) -> int:
"""Return the state of the sensor."""
return len(self._upcoming) | [
"def",
"state",
"(",
"self",
")",
"->",
"int",
":",
"return",
"len",
"(",
"self",
".",
"_upcoming",
")"
] | [
313,
4
] | [
315,
34
] | python | en | ['en', 'en', 'en'] | True |
SonarrWantedSensor.__init__ | (self, sonarr: Sonarr, entry_id: str, max_items: int = 10) | Initialize Sonarr Wanted sensor. | Initialize Sonarr Wanted sensor. | def __init__(self, sonarr: Sonarr, entry_id: str, max_items: int = 10) -> None:
"""Initialize Sonarr Wanted sensor."""
self._max_items = max_items
self._results = None
self._total: Optional[int] = None
super().__init__(
sonarr=sonarr,
entry_id=entry_id,
... | [
"def",
"__init__",
"(",
"self",
",",
"sonarr",
":",
"Sonarr",
",",
"entry_id",
":",
"str",
",",
"max_items",
":",
"int",
"=",
"10",
")",
"->",
"None",
":",
"self",
".",
"_max_items",
"=",
"max_items",
"self",
".",
"_results",
"=",
"None",
"self",
"."... | [
321,
4
] | [
335,
9
] | python | en | ['en', 'en', 'en'] | True |
SonarrWantedSensor.async_update | (self) | Update entity. | Update entity. | async def async_update(self) -> None:
"""Update entity."""
self._results = await self.sonarr.wanted(page_size=self._max_items)
self._total = self._results.total | [
"async",
"def",
"async_update",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_results",
"=",
"await",
"self",
".",
"sonarr",
".",
"wanted",
"(",
"page_size",
"=",
"self",
".",
"_max_items",
")",
"self",
".",
"_total",
"=",
"self",
".",
"_results"... | [
338,
4
] | [
341,
41
] | python | en | ['es', 'en', 'en'] | False |
SonarrWantedSensor.device_state_attributes | (self) | Return the state attributes of the entity. | Return the state attributes of the entity. | def device_state_attributes(self) -> Optional[Dict[str, Any]]:
"""Return the state attributes of the entity."""
attrs = {}
if self._results is not None:
for episode in self._results.episodes:
name = f"{episode.series.title} {episode.identifier}"
attrs... | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"attrs",
"=",
"{",
"}",
"if",
"self",
".",
"_results",
"is",
"not",
"None",
":",
"for",
"episode",
"in",
"self",
".",
"_results"... | [
344,
4
] | [
353,
20
] | python | en | ['en', 'en', 'en'] | True |
SonarrWantedSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self) -> Optional[int]:
"""Return the state of the sensor."""
return self._total | [
"def",
"state",
"(",
"self",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"return",
"self",
".",
"_total"
] | [
356,
4
] | [
358,
26
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: dict) | Set up the Met Office weather component. | Set up the Met Office weather component. | async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the Met Office weather component."""
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
":",
"return",
"True"
] | [
25,
0
] | [
27,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up a Met Office entry. | Set up a Met Office entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up a Met Office entry."""
latitude = entry.data[CONF_LATITUDE]
longitude = entry.data[CONF_LONGITUDE]
api_key = entry.data[CONF_API_KEY]
site_name = entry.data[CONF_NAME]
metoffice_data = MetOfficeData(hass, api_key, ... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"latitude",
"=",
"entry",
".",
"data",
"[",
"CONF_LATITUDE",
"]",
"longitude",
"=",
"entry",
".",
"data",
"[",
"CONF_LONGITUDE",
"]",
"api_key... | [
30,
0
] | [
68,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
)
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload... | [
71,
0
] | [
85,
20
] | python | en | ['en', 'es', 'en'] | True |
solaredge_entries | (hass: HomeAssistant) | Return the site_ids for the domain. | Return the site_ids for the domain. | def solaredge_entries(hass: HomeAssistant):
"""Return the site_ids for the domain."""
return {
(entry.data[CONF_SITE_ID])
for entry in hass.config_entries.async_entries(DOMAIN)
} | [
"def",
"solaredge_entries",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"return",
"{",
"(",
"entry",
".",
"data",
"[",
"CONF_SITE_ID",
"]",
")",
"for",
"entry",
"in",
"hass",
".",
"config_entries",
".",
"async_entries",
"(",
"DOMAIN",
")",
"}"
] | [
14,
0
] | [
19,
5
] | python | en | ['en', 'en', 'en'] | True |
SolarEdgeConfigFlow.__init__ | (self) | Initialize the config flow. | Initialize the config flow. | def __init__(self) -> None:
"""Initialize the config flow."""
self._errors = {} | [
"def",
"__init__",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_errors",
"=",
"{",
"}"
] | [
28,
4
] | [
30,
25
] | python | en | ['en', 'en', 'en'] | True |
SolarEdgeConfigFlow._site_in_configuration_exists | (self, site_id) | Return True if site_id exists in configuration. | Return True if site_id exists in configuration. | def _site_in_configuration_exists(self, site_id) -> bool:
"""Return True if site_id exists in configuration."""
if site_id in solaredge_entries(self.hass):
return True
return False | [
"def",
"_site_in_configuration_exists",
"(",
"self",
",",
"site_id",
")",
"->",
"bool",
":",
"if",
"site_id",
"in",
"solaredge_entries",
"(",
"self",
".",
"hass",
")",
":",
"return",
"True",
"return",
"False"
] | [
32,
4
] | [
36,
20
] | python | en | ['en', 'en', 'en'] | True |
SolarEdgeConfigFlow._check_site | (self, site_id, api_key) | Check if we can connect to the soleredge api service. | Check if we can connect to the soleredge api service. | def _check_site(self, site_id, api_key) -> bool:
"""Check if we can connect to the soleredge api service."""
api = solaredge.Solaredge(api_key)
try:
response = api.get_details(site_id)
except (ConnectTimeout, HTTPError):
self._errors[CONF_SITE_ID] = "could_not_con... | [
"def",
"_check_site",
"(",
"self",
",",
"site_id",
",",
"api_key",
")",
"->",
"bool",
":",
"api",
"=",
"solaredge",
".",
"Solaredge",
"(",
"api_key",
")",
"try",
":",
"response",
"=",
"api",
".",
"get_details",
"(",
"site_id",
")",
"except",
"(",
"Conn... | [
38,
4
] | [
53,
19
] | python | en | ['en', 'en', 'en'] | True |
SolarEdgeConfigFlow.async_step_user | (self, user_input=None) | Step when user initializes a integration. | Step when user initializes a integration. | async def async_step_user(self, user_input=None):
"""Step when user initializes a integration."""
self._errors = {}
if user_input is not None:
name = slugify(user_input.get(CONF_NAME, DEFAULT_NAME))
if self._site_in_configuration_exists(user_input[CONF_SITE_ID]):
... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"self",
".",
"_errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"name",
"=",
"slugify",
"(",
"user_input",
".",
"get",
"(",
"CONF_NAME",
",",... | [
55,
4
] | [
91,
9
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.