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
AbstractDemoPlayer.select_sound_mode
(self, sound_mode)
Select sound mode.
Select sound mode.
def select_sound_mode(self, sound_mode): """Select sound mode.""" self._sound_mode = sound_mode self.schedule_update_ha_state()
[ "def", "select_sound_mode", "(", "self", ",", "sound_mode", ")", ":", "self", ".", "_sound_mode", "=", "sound_mode", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 203, 4 ]
[ 206, 39 ]
python
en
['en', 'mk', 'en']
True
DemoYoutubePlayer.__init__
(self, name, youtube_id=None, media_title=None, duration=360)
Initialize the demo device.
Initialize the demo device.
def __init__(self, name, youtube_id=None, media_title=None, duration=360): """Initialize the demo device.""" super().__init__(name) self.youtube_id = youtube_id self._media_title = media_title self._duration = duration self._progress = int(duration * 0.15) self._p...
[ "def", "__init__", "(", "self", ",", "name", ",", "youtube_id", "=", "None", ",", "media_title", "=", "None", ",", "duration", "=", "360", ")", ":", "super", "(", ")", ".", "__init__", "(", "name", ")", "self", ".", "youtube_id", "=", "youtube_id", "...
[ 214, 4 ]
[ 221, 52 ]
python
en
['en', 'en', 'en']
True
DemoYoutubePlayer.media_content_id
(self)
Return the content ID of current playing media.
Return the content ID of current playing media.
def media_content_id(self): """Return the content ID of current playing media.""" return self.youtube_id
[ "def", "media_content_id", "(", "self", ")", ":", "return", "self", ".", "youtube_id" ]
[ 224, 4 ]
[ 226, 30 ]
python
en
['en', 'en', 'en']
True
DemoYoutubePlayer.media_content_type
(self)
Return the content type of current playing media.
Return the content type of current playing media.
def media_content_type(self): """Return the content type of current playing media.""" return MEDIA_TYPE_MOVIE
[ "def", "media_content_type", "(", "self", ")", ":", "return", "MEDIA_TYPE_MOVIE" ]
[ 229, 4 ]
[ 231, 31 ]
python
en
['en', 'en', 'en']
True
DemoYoutubePlayer.media_duration
(self)
Return the duration of current playing media in seconds.
Return the duration of current playing media in seconds.
def media_duration(self): """Return the duration of current playing media in seconds.""" return self._duration
[ "def", "media_duration", "(", "self", ")", ":", "return", "self", ".", "_duration" ]
[ 234, 4 ]
[ 236, 29 ]
python
en
['en', 'en', 'en']
True
DemoYoutubePlayer.media_image_url
(self)
Return the image url of current playing media.
Return the image url of current playing media.
def media_image_url(self): """Return the image url of current playing media.""" return f"https://img.youtube.com/vi/{self.youtube_id}/hqdefault.jpg"
[ "def", "media_image_url", "(", "self", ")", ":", "return", "f\"https://img.youtube.com/vi/{self.youtube_id}/hqdefault.jpg\"" ]
[ 239, 4 ]
[ 241, 76 ]
python
en
['en', 'en', 'en']
True
DemoYoutubePlayer.media_title
(self)
Return the title of current playing media.
Return the title of current playing media.
def media_title(self): """Return the title of current playing media.""" return self._media_title
[ "def", "media_title", "(", "self", ")", ":", "return", "self", ".", "_media_title" ]
[ 244, 4 ]
[ 246, 32 ]
python
en
['en', 'en', 'en']
True
DemoYoutubePlayer.app_name
(self)
Return the current running application.
Return the current running application.
def app_name(self): """Return the current running application.""" return "YouTube"
[ "def", "app_name", "(", "self", ")", ":", "return", "\"YouTube\"" ]
[ 249, 4 ]
[ 251, 24 ]
python
en
['en', 'en', 'en']
True
DemoYoutubePlayer.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.""" return YOUTUBE_PLAYER_SUPPORT
[ "def", "supported_features", "(", "self", ")", ":", "return", "YOUTUBE_PLAYER_SUPPORT" ]
[ 254, 4 ]
[ 256, 37 ]
python
en
['en', 'en', 'en']
True
DemoYoutubePlayer.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.""" if self._progress is None: return None position = self._progress if self._player_state == STATE_PLAYING: position += (dt_util.utcnow() - self._progress_updated_at).total_seconds() ...
[ "def", "media_position", "(", "self", ")", ":", "if", "self", ".", "_progress", "is", "None", ":", "return", "None", "position", "=", "self", ".", "_progress", "if", "self", ".", "_player_state", "==", "STATE_PLAYING", ":", "position", "+=", "(", "dt_util"...
[ 259, 4 ]
[ 269, 23 ]
python
en
['en', 'en', 'en']
True
DemoYoutubePlayer.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(). """ if self._player_state == STATE_PLAYING: return self._progress_updated_at
[ "def", "media_position_updated_at", "(", "self", ")", ":", "if", "self", ".", "_player_state", "==", "STATE_PLAYING", ":", "return", "self", ".", "_progress_updated_at" ]
[ 272, 4 ]
[ 278, 44 ]
python
en
['en', 'en', 'en']
True
DemoYoutubePlayer.play_media
(self, media_type, media_id, **kwargs)
Play a piece of media.
Play a piece of media.
def play_media(self, media_type, media_id, **kwargs): """Play a piece of media.""" self.youtube_id = media_id self.schedule_update_ha_state()
[ "def", "play_media", "(", "self", ",", "media_type", ",", "media_id", ",", "*", "*", "kwargs", ")", ":", "self", ".", "youtube_id", "=", "media_id", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 280, 4 ]
[ 283, 39 ]
python
en
['en', 'en', 'en']
True
DemoYoutubePlayer.media_pause
(self)
Send pause command.
Send pause command.
def media_pause(self): """Send pause command.""" self._progress = self.media_position self._progress_updated_at = dt_util.utcnow() super().media_pause()
[ "def", "media_pause", "(", "self", ")", ":", "self", ".", "_progress", "=", "self", ".", "media_position", "self", ".", "_progress_updated_at", "=", "dt_util", ".", "utcnow", "(", ")", "super", "(", ")", ".", "media_pause", "(", ")" ]
[ 285, 4 ]
[ 289, 29 ]
python
en
['en', 'en', 'en']
True
DemoMusicPlayer.__init__
(self)
Initialize the demo device.
Initialize the demo device.
def __init__(self): """Initialize the demo device.""" super().__init__("Walkman") self._cur_track = 0 self._repeat = REPEAT_MODE_OFF
[ "def", "__init__", "(", "self", ")", ":", "super", "(", ")", ".", "__init__", "(", "\"Walkman\"", ")", "self", ".", "_cur_track", "=", "0", "self", ".", "_repeat", "=", "REPEAT_MODE_OFF" ]
[ 320, 4 ]
[ 324, 38 ]
python
en
['en', 'en', 'en']
True
DemoMusicPlayer.media_content_id
(self)
Return the content ID of current playing media.
Return the content ID of current playing media.
def media_content_id(self): """Return the content ID of current playing media.""" return "bounzz-1"
[ "def", "media_content_id", "(", "self", ")", ":", "return", "\"bounzz-1\"" ]
[ 327, 4 ]
[ 329, 25 ]
python
en
['en', 'en', 'en']
True
DemoMusicPlayer.media_content_type
(self)
Return the content type of current playing media.
Return the content type of current playing media.
def media_content_type(self): """Return the content type of current playing media.""" return MEDIA_TYPE_MUSIC
[ "def", "media_content_type", "(", "self", ")", ":", "return", "MEDIA_TYPE_MUSIC" ]
[ 332, 4 ]
[ 334, 31 ]
python
en
['en', 'en', 'en']
True
DemoMusicPlayer.media_duration
(self)
Return the duration of current playing media in seconds.
Return the duration of current playing media in seconds.
def media_duration(self): """Return the duration of current playing media in seconds.""" return 213
[ "def", "media_duration", "(", "self", ")", ":", "return", "213" ]
[ 337, 4 ]
[ 339, 18 ]
python
en
['en', 'en', 'en']
True
DemoMusicPlayer.media_image_url
(self)
Return the image url of current playing media.
Return the image url of current playing media.
def media_image_url(self): """Return the image url of current playing media.""" return "https://graph.facebook.com/v2.5/107771475912710/picture?type=large"
[ "def", "media_image_url", "(", "self", ")", ":", "return", "\"https://graph.facebook.com/v2.5/107771475912710/picture?type=large\"" ]
[ 342, 4 ]
[ 344, 83 ]
python
en
['en', 'en', 'en']
True
DemoMusicPlayer.media_title
(self)
Return the title of current playing media.
Return the title of current playing media.
def media_title(self): """Return the title of current playing media.""" return self.tracks[self._cur_track][1] if self.tracks else ""
[ "def", "media_title", "(", "self", ")", ":", "return", "self", ".", "tracks", "[", "self", ".", "_cur_track", "]", "[", "1", "]", "if", "self", ".", "tracks", "else", "\"\"" ]
[ 347, 4 ]
[ 349, 69 ]
python
en
['en', 'en', 'en']
True
DemoMusicPlayer.media_artist
(self)
Return the artist of current playing media (Music track only).
Return the artist of current playing media (Music track only).
def media_artist(self): """Return the artist of current playing media (Music track only).""" return self.tracks[self._cur_track][0] if self.tracks else ""
[ "def", "media_artist", "(", "self", ")", ":", "return", "self", ".", "tracks", "[", "self", ".", "_cur_track", "]", "[", "0", "]", "if", "self", ".", "tracks", "else", "\"\"" ]
[ 352, 4 ]
[ 354, 69 ]
python
en
['en', 'en', 'en']
True
DemoMusicPlayer.media_album_name
(self)
Return the album of current playing media (Music track only).
Return the album of current playing media (Music track only).
def media_album_name(self): """Return the album of current playing media (Music track only).""" return "Bounzz"
[ "def", "media_album_name", "(", "self", ")", ":", "return", "\"Bounzz\"" ]
[ 357, 4 ]
[ 359, 23 ]
python
en
['en', 'en', 'en']
True
DemoMusicPlayer.media_track
(self)
Return the track number of current media (Music track only).
Return the track number of current media (Music track only).
def media_track(self): """Return the track number of current media (Music track only).""" return self._cur_track + 1
[ "def", "media_track", "(", "self", ")", ":", "return", "self", ".", "_cur_track", "+", "1" ]
[ 362, 4 ]
[ 364, 34 ]
python
en
['en', 'en', 'en']
True
DemoMusicPlayer.repeat
(self)
Return current repeat mode.
Return current repeat mode.
def repeat(self): """Return current repeat mode.""" return self._repeat
[ "def", "repeat", "(", "self", ")", ":", "return", "self", ".", "_repeat" ]
[ 367, 4 ]
[ 369, 27 ]
python
en
['en', 'la', 'en']
True
DemoMusicPlayer.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.""" return MUSIC_PLAYER_SUPPORT
[ "def", "supported_features", "(", "self", ")", ":", "return", "MUSIC_PLAYER_SUPPORT" ]
[ 372, 4 ]
[ 374, 35 ]
python
en
['en', 'en', 'en']
True
DemoMusicPlayer.media_previous_track
(self)
Send previous track command.
Send previous track command.
def media_previous_track(self): """Send previous track command.""" if self._cur_track > 0: self._cur_track -= 1 self.schedule_update_ha_state()
[ "def", "media_previous_track", "(", "self", ")", ":", "if", "self", ".", "_cur_track", ">", "0", ":", "self", ".", "_cur_track", "-=", "1", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 376, 4 ]
[ 380, 43 ]
python
en
['en', 'it', 'en']
True
DemoMusicPlayer.media_next_track
(self)
Send next track command.
Send next track command.
def media_next_track(self): """Send next track command.""" if self._cur_track < len(self.tracks) - 1: self._cur_track += 1 self.schedule_update_ha_state()
[ "def", "media_next_track", "(", "self", ")", ":", "if", "self", ".", "_cur_track", "<", "len", "(", "self", ".", "tracks", ")", "-", "1", ":", "self", ".", "_cur_track", "+=", "1", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 382, 4 ]
[ 386, 43 ]
python
en
['en', 'pt', 'en']
True
DemoMusicPlayer.clear_playlist
(self)
Clear players playlist.
Clear players playlist.
def clear_playlist(self): """Clear players playlist.""" self.tracks = [] self._cur_track = 0 self._player_state = STATE_OFF self.schedule_update_ha_state()
[ "def", "clear_playlist", "(", "self", ")", ":", "self", ".", "tracks", "=", "[", "]", "self", ".", "_cur_track", "=", "0", "self", ".", "_player_state", "=", "STATE_OFF", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 388, 4 ]
[ 393, 39 ]
python
en
['fr', 'en', 'en']
True
DemoMusicPlayer.set_repeat
(self, repeat)
Enable/disable repeat mode.
Enable/disable repeat mode.
def set_repeat(self, repeat): """Enable/disable repeat mode.""" self._repeat = repeat self.schedule_update_ha_state()
[ "def", "set_repeat", "(", "self", ",", "repeat", ")", ":", "self", ".", "_repeat", "=", "repeat", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 395, 4 ]
[ 398, 39 ]
python
en
['en', 'en', 'en']
True
DemoTVShowPlayer.__init__
(self)
Initialize the demo device.
Initialize the demo device.
def __init__(self): """Initialize the demo device.""" super().__init__("Lounge room") self._cur_episode = 1 self._episode_count = 13 self._source = "dvd" self._source_list = ["dvd", "youtube"]
[ "def", "__init__", "(", "self", ")", ":", "super", "(", ")", ".", "__init__", "(", "\"Lounge room\"", ")", "self", ".", "_cur_episode", "=", "1", "self", ".", "_episode_count", "=", "13", "self", ".", "_source", "=", "\"dvd\"", "self", ".", "_source_list...
[ 406, 4 ]
[ 412, 46 ]
python
en
['en', 'en', 'en']
True
DemoTVShowPlayer.media_content_id
(self)
Return the content ID of current playing media.
Return the content ID of current playing media.
def media_content_id(self): """Return the content ID of current playing media.""" return "house-of-cards-1"
[ "def", "media_content_id", "(", "self", ")", ":", "return", "\"house-of-cards-1\"" ]
[ 415, 4 ]
[ 417, 33 ]
python
en
['en', 'en', 'en']
True
DemoTVShowPlayer.media_content_type
(self)
Return the content type of current playing media.
Return the content type of current playing media.
def media_content_type(self): """Return the content type of current playing media.""" return MEDIA_TYPE_TVSHOW
[ "def", "media_content_type", "(", "self", ")", ":", "return", "MEDIA_TYPE_TVSHOW" ]
[ 420, 4 ]
[ 422, 32 ]
python
en
['en', 'en', 'en']
True
DemoTVShowPlayer.media_duration
(self)
Return the duration of current playing media in seconds.
Return the duration of current playing media in seconds.
def media_duration(self): """Return the duration of current playing media in seconds.""" return 3600
[ "def", "media_duration", "(", "self", ")", ":", "return", "3600" ]
[ 425, 4 ]
[ 427, 19 ]
python
en
['en', 'en', 'en']
True
DemoTVShowPlayer.media_image_url
(self)
Return the image url of current playing media.
Return the image url of current playing media.
def media_image_url(self): """Return the image url of current playing media.""" return "https://graph.facebook.com/v2.5/HouseofCards/picture?width=400"
[ "def", "media_image_url", "(", "self", ")", ":", "return", "\"https://graph.facebook.com/v2.5/HouseofCards/picture?width=400\"" ]
[ 430, 4 ]
[ 432, 79 ]
python
en
['en', 'en', 'en']
True
DemoTVShowPlayer.media_title
(self)
Return the title of current playing media.
Return the title of current playing media.
def media_title(self): """Return the title of current playing media.""" return f"Chapter {self._cur_episode}"
[ "def", "media_title", "(", "self", ")", ":", "return", "f\"Chapter {self._cur_episode}\"" ]
[ 435, 4 ]
[ 437, 45 ]
python
en
['en', 'en', 'en']
True
DemoTVShowPlayer.media_series_title
(self)
Return the series title of current playing media (TV Show only).
Return the series title of current playing media (TV Show only).
def media_series_title(self): """Return the series title of current playing media (TV Show only).""" return "House of Cards"
[ "def", "media_series_title", "(", "self", ")", ":", "return", "\"House of Cards\"" ]
[ 440, 4 ]
[ 442, 31 ]
python
en
['en', 'en', 'en']
True
DemoTVShowPlayer.media_season
(self)
Return the season of current playing media (TV Show only).
Return the season of current playing media (TV Show only).
def media_season(self): """Return the season of current playing media (TV Show only).""" return 1
[ "def", "media_season", "(", "self", ")", ":", "return", "1" ]
[ 445, 4 ]
[ 447, 16 ]
python
en
['en', 'en', 'en']
True
DemoTVShowPlayer.media_episode
(self)
Return the episode of current playing media (TV Show only).
Return the episode of current playing media (TV Show only).
def media_episode(self): """Return the episode of current playing media (TV Show only).""" return self._cur_episode
[ "def", "media_episode", "(", "self", ")", ":", "return", "self", ".", "_cur_episode" ]
[ 450, 4 ]
[ 452, 32 ]
python
en
['en', 'en', 'en']
True
DemoTVShowPlayer.app_name
(self)
Return the current running application.
Return the current running application.
def app_name(self): """Return the current running application.""" return "Netflix"
[ "def", "app_name", "(", "self", ")", ":", "return", "\"Netflix\"" ]
[ 455, 4 ]
[ 457, 24 ]
python
en
['en', 'en', 'en']
True
DemoTVShowPlayer.source
(self)
Return the current input source.
Return the current input source.
def source(self): """Return the current input source.""" return self._source
[ "def", "source", "(", "self", ")", ":", "return", "self", ".", "_source" ]
[ 460, 4 ]
[ 462, 27 ]
python
en
['en', 'en', 'en']
True
DemoTVShowPlayer.source_list
(self)
List of available sources.
List of available sources.
def source_list(self): """List of available sources.""" return self._source_list
[ "def", "source_list", "(", "self", ")", ":", "return", "self", ".", "_source_list" ]
[ 465, 4 ]
[ 467, 32 ]
python
en
['en', 'en', 'en']
True
DemoTVShowPlayer.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.""" return NETFLIX_PLAYER_SUPPORT
[ "def", "supported_features", "(", "self", ")", ":", "return", "NETFLIX_PLAYER_SUPPORT" ]
[ 470, 4 ]
[ 472, 37 ]
python
en
['en', 'en', 'en']
True
DemoTVShowPlayer.media_previous_track
(self)
Send previous track command.
Send previous track command.
def media_previous_track(self): """Send previous track command.""" if self._cur_episode > 1: self._cur_episode -= 1 self.schedule_update_ha_state()
[ "def", "media_previous_track", "(", "self", ")", ":", "if", "self", ".", "_cur_episode", ">", "1", ":", "self", ".", "_cur_episode", "-=", "1", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 474, 4 ]
[ 478, 43 ]
python
en
['en', 'it', 'en']
True
DemoTVShowPlayer.media_next_track
(self)
Send next track command.
Send next track command.
def media_next_track(self): """Send next track command.""" if self._cur_episode < self._episode_count: self._cur_episode += 1 self.schedule_update_ha_state()
[ "def", "media_next_track", "(", "self", ")", ":", "if", "self", ".", "_cur_episode", "<", "self", ".", "_episode_count", ":", "self", ".", "_cur_episode", "+=", "1", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 480, 4 ]
[ 484, 43 ]
python
en
['en', 'pt', 'en']
True
DemoTVShowPlayer.select_source
(self, source)
Set the input source.
Set the input source.
def select_source(self, source): """Set the input source.""" self._source = source self.schedule_update_ha_state()
[ "def", "select_source", "(", "self", ",", "source", ")", ":", "self", ".", "_source", "=", "source", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 486, 4 ]
[ 489, 39 ]
python
en
['en', 'su', 'en']
True
test_form
(hass, mock_simple_nws_config)
Test we get the form.
Test we get the form.
async def test_form(hass, mock_simple_nws_config): """Test we get the form.""" hass.config.latitude = 35 hass.config.longitude = -90 await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_e...
[ "async", "def", "test_form", "(", "hass", ",", "mock_simple_nws_config", ")", ":", "hass", ".", "config", ".", "latitude", "=", "35", "hass", ".", "config", ".", "longitude", "=", "-", "90", "await", "setup", ".", "async_setup_component", "(", "hass", ",",...
[ 9, 0 ]
[ 41, 48 ]
python
en
['en', 'en', 'en']
True
test_form_cannot_connect
(hass, mock_simple_nws_config)
Test we handle cannot connect error.
Test we handle cannot connect error.
async def test_form_cannot_connect(hass, mock_simple_nws_config): """Test we handle cannot connect error.""" mock_instance = mock_simple_nws_config.return_value mock_instance.set_station.side_effect = aiohttp.ClientError result = await hass.config_entries.flow.async_init( DOMAIN, context={"sour...
[ "async", "def", "test_form_cannot_connect", "(", "hass", ",", "mock_simple_nws_config", ")", ":", "mock_instance", "=", "mock_simple_nws_config", ".", "return_value", "mock_instance", ".", "set_station", ".", "side_effect", "=", "aiohttp", ".", "ClientError", "result", ...
[ 44, 0 ]
[ 59, 58 ]
python
en
['en', 'en', 'en']
True
test_form_unknown_error
(hass, mock_simple_nws_config)
Test we handle unknown error.
Test we handle unknown error.
async def test_form_unknown_error(hass, mock_simple_nws_config): """Test we handle unknown error.""" mock_instance = mock_simple_nws_config.return_value mock_instance.set_station.side_effect = ValueError result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entri...
[ "async", "def", "test_form_unknown_error", "(", "hass", ",", "mock_simple_nws_config", ")", ":", "mock_instance", "=", "mock_simple_nws_config", ".", "return_value", "mock_instance", ".", "set_station", ".", "side_effect", "=", "ValueError", "result", "=", "await", "h...
[ 62, 0 ]
[ 77, 51 ]
python
en
['en', 'de', 'en']
True
test_form_already_configured
(hass, mock_simple_nws_config)
Test we handle duplicate entries.
Test we handle duplicate entries.
async def test_form_already_configured(hass, mock_simple_nws_config): """Test we handle duplicate entries.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "homeassistant.components.nws.async_setup", return_value...
[ "async", "def", "test_form_already_configured", "(", "hass", ",", "mock_simple_nws_config", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entri...
[ 80, 0 ]
[ 120, 48 ]
python
en
['fr', 'en', 'en']
True
ModelContainer.check_bounds
(self, theta)
Step 6 check for overlapping periods (within 2.5% arbitrarily chosen)
Step 6 check for overlapping periods (within 2.5% arbitrarily chosen)
def check_bounds(self, theta): for ii in range(0, self.ndim): if not (self.bounds[ii, 0] < theta[ii] < self.bounds[ii, 1]): return False period_storage = [] period_storage_ordered = np.zeros(len(self.ordered_planets)) for model_name, model in self.common_mod...
[ "def", "check_bounds", "(", "self", ",", "theta", ")", ":", "for", "ii", "in", "range", "(", "0", ",", "self", ".", "ndim", ")", ":", "if", "not", "(", "self", ".", "bounds", "[", "ii", ",", "0", "]", "<", "theta", "[", "ii", "]", "<", "self"...
[ 138, 4 ]
[ 203, 19 ]
python
en
['en', 'en', 'en']
True
ModelContainer.log_priors_likelihood
(self, theta, return_priors=True)
Constant term added either by dataset.model_logchi2() or gp.log_likelihood()
Constant term added either by dataset.model_logchi2() or gp.log_likelihood()
def log_priors_likelihood(self, theta, return_priors=True): log_priors = 0.00 log_likelihood = 0.00 """ Constant term added either by dataset.model_logchi2() or gp.log_likelihood() """ if not self.check_bounds(theta): if return_priors is False: ...
[ "def", "log_priors_likelihood", "(", "self", ",", "theta", ",", "return_priors", "=", "True", ")", ":", "log_priors", "=", "0.00", "log_likelihood", "=", "0.00", "if", "not", "self", ".", "check_bounds", "(", "theta", ")", ":", "if", "return_priors", "is", ...
[ 213, 4 ]
[ 349, 45 ]
python
en
['en', 'ja', 'th']
False
icloud_bypass_setup_fixture
()
Mock component setup.
Mock component setup.
def icloud_bypass_setup_fixture(): """Mock component setup.""" with patch("homeassistant.components.icloud.async_setup_entry", return_value=True): yield
[ "def", "icloud_bypass_setup_fixture", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.icloud.async_setup_entry\"", ",", "return_value", "=", "True", ")", ":", "yield" ]
[ 7, 0 ]
[ 10, 13 ]
python
en
['en', 'bg', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Tahoma covers.
Set up the Tahoma covers.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Tahoma covers.""" if discovery_info is None: return controller = hass.data[TAHOMA_DOMAIN]["controller"] devices = [] for device in hass.data[TAHOMA_DOMAIN]["devices"]["cover"]: devices.append(TahomaCov...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "controller", "=", "hass", ".", "data", "[", "TAHOMA_DOMAIN", "]", "[", "\"controller...
[ 52, 0 ]
[ 60, 31 ]
python
en
['en', 'en', 'en']
True
TahomaCover.__init__
(self, tahoma_device, controller)
Initialize the device.
Initialize the device.
def __init__(self, tahoma_device, controller): """Initialize the device.""" super().__init__(tahoma_device, controller) self._closure = 0 # 100 equals open self._position = 100 self._closed = False self._rssi_level = None self._icon = None # Can b...
[ "def", "__init__", "(", "self", ",", "tahoma_device", ",", "controller", ")", ":", "super", "(", ")", ".", "__init__", "(", "tahoma_device", ",", "controller", ")", "self", ".", "_closure", "=", "0", "# 100 equals open", "self", ".", "_position", "=", "100...
[ 66, 4 ]
[ 86, 36 ]
python
en
['en', 'en', 'en']
True
TahomaCover.update
(self)
Update method.
Update method.
def update(self): """Update method.""" self.controller.get_states([self.tahoma_device]) # For vertical covers self._closure = self.tahoma_device.active_states.get("core:ClosureState") # For horizontal covers if self._closure is None: self._closure = self.taho...
[ "def", "update", "(", "self", ")", ":", "self", ".", "controller", ".", "get_states", "(", "[", "self", ".", "tahoma_device", "]", ")", "# For vertical covers", "self", ".", "_closure", "=", "self", ".", "tahoma_device", ".", "active_states", ".", "get", "...
[ 88, 4 ]
[ 166, 76 ]
python
en
['en', 'nl', 'en']
False
TahomaCover.current_cover_position
(self)
Return current position of cover.
Return current position of cover.
def current_cover_position(self): """Return current position of cover.""" return self._position
[ "def", "current_cover_position", "(", "self", ")", ":", "return", "self", ".", "_position" ]
[ 169, 4 ]
[ 171, 29 ]
python
en
['en', 'en', 'en']
True
TahomaCover.set_cover_position
(self, **kwargs)
Move the cover to a specific position.
Move the cover to a specific position.
def set_cover_position(self, **kwargs): """Move the cover to a specific position.""" if self.tahoma_device.type == "io:WindowOpenerVeluxIOComponent": command = "setClosure" else: command = "setPosition" if self.tahoma_device.type == HORIZONTAL_AWNING: ...
[ "def", "set_cover_position", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "tahoma_device", ".", "type", "==", "\"io:WindowOpenerVeluxIOComponent\"", ":", "command", "=", "\"setClosure\"", "else", ":", "command", "=", "\"setPosition\"", "if"...
[ 173, 4 ]
[ 183, 74 ]
python
en
['en', 'en', 'en']
True
TahomaCover.is_closed
(self)
Return if the cover is closed.
Return if the cover is closed.
def is_closed(self): """Return if the cover is closed.""" return self._closed
[ "def", "is_closed", "(", "self", ")", ":", "return", "self", ".", "_closed" ]
[ 186, 4 ]
[ 188, 27 ]
python
en
['en', 'en', 'en']
True
TahomaCover.device_class
(self)
Return the class of the device.
Return the class of the device.
def device_class(self): """Return the class of the device.""" return TAHOMA_DEVICE_CLASSES.get(self.tahoma_device.type)
[ "def", "device_class", "(", "self", ")", ":", "return", "TAHOMA_DEVICE_CLASSES", ".", "get", "(", "self", ".", "tahoma_device", ".", "type", ")" ]
[ 191, 4 ]
[ 193, 65 ]
python
en
['en', 'en', 'en']
True
TahomaCover.device_state_attributes
(self)
Return the device state attributes.
Return the device state attributes.
def device_state_attributes(self): """Return the device state attributes.""" attr = {} super_attr = super().device_state_attributes if super_attr is not None: attr.update(super_attr) if "core:Memorized1PositionState" in self.tahoma_device.active_states: a...
[ "def", "device_state_attributes", "(", "self", ")", ":", "attr", "=", "{", "}", "super_attr", "=", "super", "(", ")", ".", "device_state_attributes", "if", "super_attr", "is", "not", "None", ":", "attr", ".", "update", "(", "super_attr", ")", "if", "\"core...
[ 196, 4 ]
[ 217, 19 ]
python
en
['en', 'en', 'en']
True
TahomaCover.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 self._icon
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_icon" ]
[ 220, 4 ]
[ 222, 25 ]
python
en
['en', 'en', 'en']
True
TahomaCover.open_cover
(self, **kwargs)
Open the cover.
Open the cover.
def open_cover(self, **kwargs): """Open the cover.""" self.apply_action("open")
[ "def", "open_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "apply_action", "(", "\"open\"", ")" ]
[ 224, 4 ]
[ 226, 33 ]
python
en
['en', 'en', 'en']
True
TahomaCover.close_cover
(self, **kwargs)
Close the cover.
Close the cover.
def close_cover(self, **kwargs): """Close the cover.""" self.apply_action("close")
[ "def", "close_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "apply_action", "(", "\"close\"", ")" ]
[ 228, 4 ]
[ 230, 34 ]
python
en
['en', 'en', 'en']
True
TahomaCover.stop_cover
(self, **kwargs)
Stop the cover.
Stop the cover.
def stop_cover(self, **kwargs): """Stop the cover.""" if ( self.tahoma_device.type == "io:RollerShutterWithLowSpeedManagementIOComponent" ): self.apply_action("setPosition", "secured") elif self.tahoma_device.type in { "io:ExteriorVenetianB...
[ "def", "stop_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "(", "self", ".", "tahoma_device", ".", "type", "==", "\"io:RollerShutterWithLowSpeedManagementIOComponent\"", ")", ":", "self", ".", "apply_action", "(", "\"setPosition\"", ",", "\"secur...
[ 232, 4 ]
[ 257, 45 ]
python
en
['en', 'en', 'en']
True
setup
(hass, base_config)
Set up the Lutron component.
Set up the Lutron component.
def setup(hass, base_config): """Set up the Lutron component.""" hass.data[LUTRON_BUTTONS] = [] hass.data[LUTRON_CONTROLLER] = None hass.data[LUTRON_DEVICES] = { "light": [], "cover": [], "switch": [], "scene": [], "binary_sensor": [], } config = base_con...
[ "def", "setup", "(", "hass", ",", "base_config", ")", ":", "hass", ".", "data", "[", "LUTRON_BUTTONS", "]", "=", "[", "]", "hass", ".", "data", "[", "LUTRON_CONTROLLER", "]", "=", "None", "hass", ".", "data", "[", "LUTRON_DEVICES", "]", "=", "{", "\"...
[ 38, 0 ]
[ 96, 15 ]
python
en
['en', 'en', 'en']
True
LutronDevice.__init__
(self, area_name, lutron_device, controller)
Initialize the device.
Initialize the device.
def __init__(self, area_name, lutron_device, controller): """Initialize the device.""" self._lutron_device = lutron_device self._controller = controller self._area_name = area_name
[ "def", "__init__", "(", "self", ",", "area_name", ",", "lutron_device", ",", "controller", ")", ":", "self", ".", "_lutron_device", "=", "lutron_device", "self", ".", "_controller", "=", "controller", "self", ".", "_area_name", "=", "area_name" ]
[ 102, 4 ]
[ 106, 35 ]
python
en
['en', 'en', 'en']
True
LutronDevice.async_added_to_hass
(self)
Register callbacks.
Register callbacks.
async def async_added_to_hass(self): """Register callbacks.""" self.hass.async_add_executor_job( self._lutron_device.subscribe, self._update_callback, None )
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "_lutron_device", ".", "subscribe", ",", "self", ".", "_update_callback", ",", "None", ")" ]
[ 108, 4 ]
[ 112, 9 ]
python
en
['en', 'no', 'en']
False
LutronDevice._update_callback
(self, _device, _context, _event, _params)
Run when invoked by pylutron when the device state changes.
Run when invoked by pylutron when the device state changes.
def _update_callback(self, _device, _context, _event, _params): """Run when invoked by pylutron when the device state changes.""" self.schedule_update_ha_state()
[ "def", "_update_callback", "(", "self", ",", "_device", ",", "_context", ",", "_event", ",", "_params", ")", ":", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 114, 4 ]
[ 116, 39 ]
python
en
['en', 'en', 'en']
True
LutronDevice.name
(self)
Return the name of the device.
Return the name of the device.
def name(self): """Return the name of the device.""" return f"{self._area_name} {self._lutron_device.name}"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self._area_name} {self._lutron_device.name}\"" ]
[ 119, 4 ]
[ 121, 62 ]
python
en
['en', 'en', 'en']
True
LutronDevice.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 124, 4 ]
[ 126, 20 ]
python
en
['en', 'en', 'en']
True
LutronButton.__init__
(self, hass, area_name, keypad, button)
Register callback for activity on the button.
Register callback for activity on the button.
def __init__(self, hass, area_name, keypad, button): """Register callback for activity on the button.""" name = f"{keypad.name}: {button.name}" self._hass = hass self._has_release_event = ( button.button_type is not None and "RaiseLower" in button.button_type ) ...
[ "def", "__init__", "(", "self", ",", "hass", ",", "area_name", ",", "keypad", ",", "button", ")", ":", "name", "=", "f\"{keypad.name}: {button.name}\"", "self", ".", "_hass", "=", "hass", "self", ".", "_has_release_event", "=", "(", "button", ".", "button_ty...
[ 137, 4 ]
[ 152, 52 ]
python
en
['en', 'en', 'en']
True
LutronButton.button_callback
(self, button, context, event, params)
Fire an event about a button being pressed or released.
Fire an event about a button being pressed or released.
def button_callback(self, button, context, event, params): """Fire an event about a button being pressed or released.""" # Events per button type: # RaiseLower -> pressed/released # SingleAction -> single action = None if self._has_release_event: if event ...
[ "def", "button_callback", "(", "self", ",", "button", ",", "context", ",", "event", ",", "params", ")", ":", "# Events per button type:", "# RaiseLower -> pressed/released", "# SingleAction -> single", "action", "=", "None", "if", "self", ".", "_has_release_event", ...
[ 154, 4 ]
[ 170, 50 ]
python
en
['en', 'en', 'en']
True
shift_tokens_right
(input_ids: torch.Tensor, pad_token_id: int, decoder_start_token_id: int)
Shift input ids one token to the right.
Shift input ids one token to the right.
def shift_tokens_right(input_ids: torch.Tensor, pad_token_id: int, decoder_start_token_id: int): """ Shift input ids one token to the right. """ shifted_input_ids = input_ids.new_zeros(input_ids.shape) shifted_input_ids[:, 1:] = input_ids[:, :-1].clone() shifted_input_ids[:, 0] = decoder_start_t...
[ "def", "shift_tokens_right", "(", "input_ids", ":", "torch", ".", "Tensor", ",", "pad_token_id", ":", "int", ",", "decoder_start_token_id", ":", "int", ")", ":", "shifted_input_ids", "=", "input_ids", ".", "new_zeros", "(", "input_ids", ".", "shape", ")", "shi...
[ 58, 0 ]
[ 70, 28 ]
python
en
['en', 'error', 'th']
False
_make_causal_mask
(input_ids_shape: torch.Size, dtype: torch.dtype, past_key_values_length: int = 0)
Make causal mask used for bi-directional self-attention.
Make causal mask used for bi-directional self-attention.
def _make_causal_mask(input_ids_shape: torch.Size, dtype: torch.dtype, past_key_values_length: int = 0): """ Make causal mask used for bi-directional self-attention. """ bsz, tgt_len = input_ids_shape mask = torch.full((tgt_len, tgt_len), float("-inf")) mask_cond = torch.arange(mask.size(-1)) ...
[ "def", "_make_causal_mask", "(", "input_ids_shape", ":", "torch", ".", "Size", ",", "dtype", ":", "torch", ".", "dtype", ",", "past_key_values_length", ":", "int", "=", "0", ")", ":", "bsz", ",", "tgt_len", "=", "input_ids_shape", "mask", "=", "torch", "."...
[ 74, 0 ]
[ 86, 91 ]
python
en
['en', 'error', 'th']
False
_expand_mask
(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None)
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
def _expand_mask(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None): """ Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`. """ bsz, src_len = mask.size() tgt_len = tgt_len if tgt_len is not None else src_len expanded_mask = mask[:, None, N...
[ "def", "_expand_mask", "(", "mask", ":", "torch", ".", "Tensor", ",", "dtype", ":", "torch", ".", "dtype", ",", "tgt_len", ":", "Optional", "[", "int", "]", "=", "None", ")", ":", "bsz", ",", "src_len", "=", "mask", ".", "size", "(", ")", "tgt_len"...
[ 90, 0 ]
[ 101, 82 ]
python
en
['en', 'error', 'th']
False
create_position_ids_from_input_ids
(input_ids, padding_idx, past_key_values_length=0)
Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols are ignored. This is modified from fairseq's `utils.make_positions`.
Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols are ignored. This is modified from fairseq's `utils.make_positions`.
def create_position_ids_from_input_ids(input_ids, padding_idx, past_key_values_length=0): """ Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols are ignored. This is modified from fairseq's `utils.make_positions`. """ # The series of cas...
[ "def", "create_position_ids_from_input_ids", "(", "input_ids", ",", "padding_idx", ",", "past_key_values_length", "=", "0", ")", ":", "# The series of casts and type-conversions here are carefully balanced to both work with ONNX export and XLA.", "mask", "=", "input_ids", ".", "ne"...
[ 104, 0 ]
[ 112, 51 ]
python
en
['en', 'error', 'th']
False
M2M100SinusoidalPositionalEmbedding.get_embedding
(num_embeddings: int, embedding_dim: int, padding_idx: Optional[int] = None)
Build sinusoidal embeddings. This matches the implementation in tensor2tensor, but differs slightly from the description in Section 3.5 of "Attention Is All You Need".
Build sinusoidal embeddings.
def get_embedding(num_embeddings: int, embedding_dim: int, padding_idx: Optional[int] = None): """ Build sinusoidal embeddings. This matches the implementation in tensor2tensor, but differs slightly from the description in Section 3.5 of "Attention Is All You Need". """ ...
[ "def", "get_embedding", "(", "num_embeddings", ":", "int", ",", "embedding_dim", ":", "int", ",", "padding_idx", ":", "Optional", "[", "int", "]", "=", "None", ")", ":", "half_dim", "=", "embedding_dim", "//", "2", "emb", "=", "math", ".", "log", "(", ...
[ 136, 4 ]
[ 154, 18 ]
python
en
['en', 'error', 'th']
False
M2M100SinusoidalPositionalEmbedding.create_position_ids_from_inputs_embeds
(self, inputs_embeds)
We are provided embeddings directly. We cannot infer which are padded so just generate sequential position ids. Args: inputs_embeds: torch.Tensor Returns: torch.Tensor
We are provided embeddings directly. We cannot infer which are padded so just generate sequential position ids.
def create_position_ids_from_inputs_embeds(self, inputs_embeds): """ We are provided embeddings directly. We cannot infer which are padded so just generate sequential position ids. Args: inputs_embeds: torch.Tensor Returns: torch.Tensor """ input_shape = inp...
[ "def", "create_position_ids_from_inputs_embeds", "(", "self", ",", "inputs_embeds", ")", ":", "input_shape", "=", "inputs_embeds", ".", "size", "(", ")", "[", ":", "-", "1", "]", "sequence_length", "=", "input_shape", "[", "1", "]", "position_ids", "=", "torch...
[ 177, 4 ]
[ 192, 73 ]
python
en
['en', 'error', 'th']
False
M2M100Attention.forward
( self, hidden_states: torch.Tensor, key_value_states: Optional[torch.Tensor] = None, past_key_value: Optional[Tuple[torch.Tensor]] = None, attention_mask: Optional[torch.Tensor] = None, layer_head_mask: Optional[torch.Tensor] = None, output_attentions: bool = Fal...
Input shape: Batch x Time x Channel
Input shape: Batch x Time x Channel
def forward( self, hidden_states: torch.Tensor, key_value_states: Optional[torch.Tensor] = None, past_key_value: Optional[Tuple[torch.Tensor]] = None, attention_mask: Optional[torch.Tensor] = None, layer_head_mask: Optional[torch.Tensor] = None, output_attentions:...
[ "def", "forward", "(", "self", ",", "hidden_states", ":", "torch", ".", "Tensor", ",", "key_value_states", ":", "Optional", "[", "torch", ".", "Tensor", "]", "=", "None", ",", "past_key_value", ":", "Optional", "[", "Tuple", "[", "torch", ".", "Tensor", ...
[ 226, 4 ]
[ 335, 65 ]
python
en
['en', 'pl', 'en']
True
M2M100EncoderLayer.forward
( self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, layer_head_mask: torch.Tensor, output_attentions: bool = False, )
Args: hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed_dim)` attention_mask (:obj:`torch.FloatTensor`): attention mask of size `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values. ...
Args: hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed_dim)` attention_mask (:obj:`torch.FloatTensor`): attention mask of size `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values. ...
def forward( self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, layer_head_mask: torch.Tensor, output_attentions: bool = False, ): """ Args: hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed...
[ "def", "forward", "(", "self", ",", "hidden_states", ":", "torch", ".", "Tensor", ",", "attention_mask", ":", "torch", ".", "Tensor", ",", "layer_head_mask", ":", "torch", ".", "Tensor", ",", "output_attentions", ":", "bool", "=", "False", ",", ")", ":", ...
[ 356, 4 ]
[ 404, 22 ]
python
en
['en', 'error', 'th']
False
M2M100DecoderLayer.forward
( self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor] = None, encoder_hidden_states: Optional[torch.Tensor] = None, encoder_attention_mask: Optional[torch.Tensor] = None, layer_head_mask: Optional[torch.Tensor] = None, encoder_layer_head_mask...
Args: hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed_dim)` attention_mask (:obj:`torch.FloatTensor`): attention mask of size `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values. ...
Args: hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed_dim)` attention_mask (:obj:`torch.FloatTensor`): attention mask of size `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values. ...
def forward( self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor] = None, encoder_hidden_states: Optional[torch.Tensor] = None, encoder_attention_mask: Optional[torch.Tensor] = None, layer_head_mask: Optional[torch.Tensor] = None, encoder_laye...
[ "def", "forward", "(", "self", ",", "hidden_states", ":", "torch", ".", "Tensor", ",", "attention_mask", ":", "Optional", "[", "torch", ".", "Tensor", "]", "=", "None", ",", "encoder_hidden_states", ":", "Optional", "[", "torch", ".", "Tensor", "]", "=", ...
[ 435, 4 ]
[ 521, 22 ]
python
en
['en', 'error', 'th']
False
M2M100Encoder.forward
( self, input_ids=None, attention_mask=None, head_mask=None, inputs_embeds=None, output_attentions=None, output_hidden_states=None, return_dict=None, )
r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide it. Indices can be obtained using :class:`~transfor...
r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide it.
def forward( self, input_ids=None, attention_mask=None, head_mask=None, inputs_embeds=None, output_attentions=None, output_hidden_states=None, return_dict=None, ): r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:...
[ "def", "forward", "(", "self", ",", "input_ids", "=", "None", ",", "attention_mask", "=", "None", ",", "head_mask", "=", "None", ",", "inputs_embeds", "=", "None", ",", "output_attentions", "=", "None", ",", "output_hidden_states", "=", "None", ",", "return_...
[ 673, 4 ]
[ 796, 9 ]
python
cy
['en', 'cy', 'hi']
False
M2M100Decoder.forward
( self, input_ids=None, attention_mask=None, encoder_hidden_states=None, encoder_attention_mask=None, head_mask=None, encoder_head_mask=None, past_key_values=None, inputs_embeds=None, use_cache=None, output_attentions=None, ...
r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide it. Indices can be obtained using :class:`~transfor...
r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide it.
def forward( self, input_ids=None, attention_mask=None, encoder_hidden_states=None, encoder_attention_mask=None, head_mask=None, encoder_head_mask=None, past_key_values=None, inputs_embeds=None, use_cache=None, output_attentions=Non...
[ "def", "forward", "(", "self", ",", "input_ids", "=", "None", ",", "attention_mask", "=", "None", ",", "encoder_hidden_states", "=", "None", ",", "encoder_attention_mask", "=", "None", ",", "head_mask", "=", "None", ",", "encoder_head_mask", "=", "None", ",", ...
[ 831, 4 ]
[ 1034, 9 ]
python
cy
['en', 'cy', 'hi']
False
device_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def device_reg(hass): """Return an empty, loaded, registry.""" return mock_device_registry(hass)
[ "def", "device_reg", "(", "hass", ")", ":", "return", "mock_device_registry", "(", "hass", ")" ]
[ 24, 0 ]
[ 26, 37 ]
python
en
['en', 'fy', 'en']
True
entity_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def entity_reg(hass): """Return an empty, loaded, registry.""" return mock_registry(hass)
[ "def", "entity_reg", "(", "hass", ")", ":", "return", "mock_registry", "(", "hass", ")" ]
[ 30, 0 ]
[ 32, 30 ]
python
en
['en', 'fy', 'en']
True
calls
(hass)
Track calls to a mock service.
Track calls to a mock service.
def calls(hass): """Track calls to a mock service.""" return async_mock_service(hass, "test", "automation")
[ "def", "calls", "(", "hass", ")", ":", "return", "async_mock_service", "(", "hass", ",", "\"test\"", ",", "\"automation\"", ")" ]
[ 36, 0 ]
[ 38, 57 ]
python
en
['en', 'en', 'en']
True
test_get_conditions
(hass, device_reg, entity_reg)
Test we get the expected conditions from a remote.
Test we get the expected conditions from a remote.
async def test_get_conditions(hass, device_reg, entity_reg): """Test we get the expected conditions from a remote.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( config_entry_id=config_entry.entry_id, ...
[ "async", "def", "test_get_conditions", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"test\"", ",", "data", "=", "{", "}", ")", "config_entry", ".", "add_to_hass", "(", "hass", ")",...
[ 41, 0 ]
[ 67, 44 ]
python
en
['en', 'en', 'en']
True
test_get_condition_capabilities
(hass, device_reg, entity_reg)
Test we get the expected capabilities from a remote condition.
Test we get the expected capabilities from a remote condition.
async def test_get_condition_capabilities(hass, device_reg, entity_reg): """Test we get the expected capabilities from a remote condition.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( config_entry_id=confi...
[ "async", "def", "test_get_condition_capabilities", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"test\"", ",", "data", "=", "{", "}", ")", "config_entry", ".", "add_to_hass", "(", "h...
[ 70, 0 ]
[ 89, 52 ]
python
en
['en', 'en', 'en']
True
test_if_state
(hass, calls)
Test for turn_on and turn_off conditions.
Test for turn_on and turn_off conditions.
async def test_if_state(hass, calls): """Test for turn_on and turn_off conditions.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}}) await hass.async_block_till_done() ent1, ent2, ent3 = ...
[ "async", "def", "test_if_state", "(", "hass", ",", "calls", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "assert", "await", "async_setup_component", "(", "hass", ",",...
[ 92, 0 ]
[ 163, 64 ]
python
en
['en', 'en', 'en']
True
test_if_fires_on_for_condition
(hass, calls)
Test for firing if condition is on with delay.
Test for firing if condition is on with delay.
async def test_if_fires_on_for_condition(hass, calls): """Test for firing if condition is on with delay.""" point1 = dt_util.utcnow() point2 = point1 + timedelta(seconds=10) point3 = point2 + timedelta(seconds=10) platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() assert...
[ "async", "def", "test_if_fires_on_for_condition", "(", "hass", ",", "calls", ")", ":", "point1", "=", "dt_util", ".", "utcnow", "(", ")", "point2", "=", "point1", "+", "timedelta", "(", "seconds", "=", "10", ")", "point3", "=", "point2", "+", "timedelta", ...
[ 166, 0 ]
[ 234, 68 ]
python
en
['en', 'en', 'en']
True
test_config_entry_not_ready
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test the Elgato Key Light configuration entry not ready.
Test the Elgato Key Light configuration entry not ready.
async def test_config_entry_not_ready( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test the Elgato Key Light configuration entry not ready.""" aioclient_mock.get( "http://1.2.3.4:9123/elgato/accessory-info", exc=aiohttp.ClientError ) entry = await init_integration...
[ "async", "def", "test_config_entry_not_ready", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "aioclient_mock", ".", "get", "(", "\"http://1.2.3.4:9123/elgato/accessory-info\"", ",", "exc", "=", "aiohttp", ...
[ 11, 0 ]
[ 20, 49 ]
python
en
['en', 'en', 'en']
True
test_unload_config_entry
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test the Elgato Key Light configuration entry unloading.
Test the Elgato Key Light configuration entry unloading.
async def test_unload_config_entry( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test the Elgato Key Light configuration entry unloading.""" entry = await init_integration(hass, aioclient_mock) assert hass.data[DOMAIN] await hass.config_entries.async_unload(entry.entry_id)...
[ "async", "def", "test_unload_config_entry", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "entry", "=", "await", "init_integration", "(", "hass", ",", "aioclient_mock", ")", "assert", "hass", ".", "...
[ 23, 0 ]
[ 32, 36 ]
python
en
['en', 'zu', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up Hikvision camera.
Set up Hikvision camera.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up Hikvision camera.""" host = config.get(CONF_HOST) port = config.get(CONF_PORT) name = config.get(CONF_NAME) username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) try: hikvision_cam = h...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "host", "=", "config", ".", "get", "(", "CONF_HOST", ")", "port", "=", "config", ".", "get", "(", "CONF_PORT", ")", "name", "=", "co...
[ 39, 0 ]
[ 58, 62 ]
python
en
['en', 'da', 'en']
True
HikvisionMotionSwitch.__init__
(self, name, hikvision_cam)
Initialize the switch.
Initialize the switch.
def __init__(self, name, hikvision_cam): """Initialize the switch.""" self._name = name self._hikvision_cam = hikvision_cam self._state = STATE_OFF
[ "def", "__init__", "(", "self", ",", "name", ",", "hikvision_cam", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_hikvision_cam", "=", "hikvision_cam", "self", ".", "_state", "=", "STATE_OFF" ]
[ 64, 4 ]
[ 68, 31 ]
python
en
['en', 'en', 'en']
True
HikvisionMotionSwitch.name
(self)
Return the name of the device if any.
Return the name of the device if any.
def name(self): """Return the name of the device if any.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 71, 4 ]
[ 73, 25 ]
python
en
['en', 'en', 'en']
True
HikvisionMotionSwitch.state
(self)
Return the state of the device if any.
Return the state of the device if any.
def state(self): """Return the state of the device if any.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 76, 4 ]
[ 78, 26 ]
python
en
['en', 'en', 'en']
True
HikvisionMotionSwitch.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self): """Return true if device is on.""" return self._state == STATE_ON
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state", "==", "STATE_ON" ]
[ 81, 4 ]
[ 83, 38 ]
python
en
['en', 'fy', 'en']
True
HikvisionMotionSwitch.turn_on
(self, **kwargs)
Turn the device on.
Turn the device on.
def turn_on(self, **kwargs): """Turn the device on.""" _LOGGING.info("Turning on Motion Detection ") self._hikvision_cam.enable_motion_detection()
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "_LOGGING", ".", "info", "(", "\"Turning on Motion Detection \"", ")", "self", ".", "_hikvision_cam", ".", "enable_motion_detection", "(", ")" ]
[ 85, 4 ]
[ 88, 53 ]
python
en
['en', 'en', 'en']
True
HikvisionMotionSwitch.turn_off
(self, **kwargs)
Turn the device off.
Turn the device off.
def turn_off(self, **kwargs): """Turn the device off.""" _LOGGING.info("Turning off Motion Detection ") self._hikvision_cam.disable_motion_detection()
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "_LOGGING", ".", "info", "(", "\"Turning off Motion Detection \"", ")", "self", ".", "_hikvision_cam", ".", "disable_motion_detection", "(", ")" ]
[ 90, 4 ]
[ 93, 54 ]
python
en
['en', 'en', 'en']
True
HikvisionMotionSwitch.update
(self)
Update Motion Detection state.
Update Motion Detection state.
def update(self): """Update Motion Detection state.""" enabled = self._hikvision_cam.is_motion_detection_enabled() _LOGGING.info("enabled: %s", enabled) self._state = STATE_ON if enabled else STATE_OFF
[ "def", "update", "(", "self", ")", ":", "enabled", "=", "self", ".", "_hikvision_cam", ".", "is_motion_detection_enabled", "(", ")", "_LOGGING", ".", "info", "(", "\"enabled: %s\"", ",", "enabled", ")", "self", ".", "_state", "=", "STATE_ON", "if", "enabled"...
[ 95, 4 ]
[ 100, 56 ]
python
en
['da', 'en', 'en']
True
async_activate_log_queue_handler
(hass: HomeAssistant)
Migrate the existing log handlers to use the queue. This allows us to avoid blocking I/O and formatting messages in the event loop as log messages are written in another thread.
Migrate the existing log handlers to use the queue.
def async_activate_log_queue_handler(hass: HomeAssistant) -> None: """ Migrate the existing log handlers to use the queue. This allows us to avoid blocking I/O and formatting messages in the event loop as log messages are written in another thread. """ simple_queue = queue.SimpleQueue() # type...
[ "def", "async_activate_log_queue_handler", "(", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "simple_queue", "=", "queue", ".", "SimpleQueue", "(", ")", "# type: ignore", "queue_handler", "=", "HomeAssistantQueueHandler", "(", "simple_queue", ")", "logging", ...
[ 61, 0 ]
[ 89, 84 ]
python
en
['en', 'error', 'th']
False