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
async_get_handler
(hass, config, discovery_info=None)
Set up the Demo mailbox.
Set up the Demo mailbox.
async def async_get_handler(hass, config, discovery_info=None): """Set up the Demo mailbox.""" return DemoMailbox(hass, MAILBOX_NAME)
[ "async", "def", "async_get_handler", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "return", "DemoMailbox", "(", "hass", ",", "MAILBOX_NAME", ")" ]
[ 13, 0 ]
[ 15, 42 ]
python
en
['en', 'pt', 'en']
True
DemoMailbox.__init__
(self, hass, name)
Initialize Demo mailbox.
Initialize Demo mailbox.
def __init__(self, hass, name): """Initialize Demo mailbox.""" super().__init__(hass, name) self._messages = {} txt = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " for idx in range(0, 10): msgtime = int(dt.as_timestamp(dt.utcnow()) - 3600 * 24 * (10 - id...
[ "def", "__init__", "(", "self", ",", "hass", ",", "name", ")", ":", "super", "(", ")", ".", "__init__", "(", "hass", ",", "name", ")", "self", ".", "_messages", "=", "{", "}", "txt", "=", "\"Lorem ipsum dolor sit amet, consectetur adipiscing elit. \"", "for"...
[ 21, 4 ]
[ 39, 40 ]
python
it
['lt', 'pt', 'it']
False
DemoMailbox.media_type
(self)
Return the supported media type.
Return the supported media type.
def media_type(self): """Return the supported media type.""" return CONTENT_TYPE_MPEG
[ "def", "media_type", "(", "self", ")", ":", "return", "CONTENT_TYPE_MPEG" ]
[ 42, 4 ]
[ 44, 32 ]
python
en
['en', 'en', 'en']
True
DemoMailbox.can_delete
(self)
Return if messages can be deleted.
Return if messages can be deleted.
def can_delete(self): """Return if messages can be deleted.""" return True
[ "def", "can_delete", "(", "self", ")", ":", "return", "True" ]
[ 47, 4 ]
[ 49, 19 ]
python
en
['en', 'en', 'en']
True
DemoMailbox.has_media
(self)
Return if messages have attached media files.
Return if messages have attached media files.
def has_media(self): """Return if messages have attached media files.""" return True
[ "def", "has_media", "(", "self", ")", ":", "return", "True" ]
[ 52, 4 ]
[ 54, 19 ]
python
en
['en', 'en', 'en']
True
DemoMailbox.async_get_media
(self, msgid)
Return the media blob for the msgid.
Return the media blob for the msgid.
async def async_get_media(self, msgid): """Return the media blob for the msgid.""" if msgid not in self._messages: raise StreamError("Message not found") audio_path = os.path.join(os.path.dirname(__file__), "tts.mp3") with open(audio_path, "rb") as file: return f...
[ "async", "def", "async_get_media", "(", "self", ",", "msgid", ")", ":", "if", "msgid", "not", "in", "self", ".", "_messages", ":", "raise", "StreamError", "(", "\"Message not found\"", ")", "audio_path", "=", "os", ".", "path", ".", "join", "(", "os", "....
[ 56, 4 ]
[ 63, 30 ]
python
en
['en', 'no', 'en']
True
DemoMailbox.async_get_messages
(self)
Return a list of the current messages.
Return a list of the current messages.
async def async_get_messages(self): """Return a list of the current messages.""" return sorted( self._messages.values(), key=lambda item: item["info"]["origtime"], reverse=True, )
[ "async", "def", "async_get_messages", "(", "self", ")", ":", "return", "sorted", "(", "self", ".", "_messages", ".", "values", "(", ")", ",", "key", "=", "lambda", "item", ":", "item", "[", "\"info\"", "]", "[", "\"origtime\"", "]", ",", "reverse", "="...
[ 65, 4 ]
[ 71, 9 ]
python
en
['en', 'en', 'en']
True
DemoMailbox.async_delete
(self, msgid)
Delete the specified messages.
Delete the specified messages.
async def async_delete(self, msgid): """Delete the specified messages.""" if msgid in self._messages: _LOGGER.info("Deleting: %s", msgid) del self._messages[msgid] self.async_update() return True
[ "async", "def", "async_delete", "(", "self", ",", "msgid", ")", ":", "if", "msgid", "in", "self", ".", "_messages", ":", "_LOGGER", ".", "info", "(", "\"Deleting: %s\"", ",", "msgid", ")", "del", "self", ".", "_messages", "[", "msgid", "]", "self", "."...
[ 73, 4 ]
[ 79, 19 ]
python
en
['en', 'en', 'en']
True
test_setup_with_no_config
(hass)
Test that no config is successful.
Test that no config is successful.
async def test_setup_with_no_config(hass): """Test that no config is successful.""" assert await async_setup_component(hass, DOMAIN, {}) is True await hass.async_block_till_done() # Assert no flows were started. assert len(hass.config_entries.flow.async_progress()) == 0
[ "async", "def", "test_setup_with_no_config", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "}", ")", "is", "True", "await", "hass", ".", "async_block_till_done", "(", ")", "# Assert no flows were started."...
[ 20, 0 ]
[ 26, 62 ]
python
en
['en', 'en', 'en']
True
test_auth_failure
(hass, config_entry, aioclient_mock)
Test if user's username or password is not accepted.
Test if user's username or password is not accepted.
async def test_auth_failure(hass, config_entry, aioclient_mock): """Test if user's username or password is not accepted.""" await setup_integration(hass, config_entry, aioclient_mock, auth_fail=True) assert config_entry.state == ENTRY_STATE_SETUP_ERROR
[ "async", "def", "test_auth_failure", "(", "hass", ",", "config_entry", ",", "aioclient_mock", ")", ":", "await", "setup_integration", "(", "hass", ",", "config_entry", ",", "aioclient_mock", ",", "auth_fail", "=", "True", ")", "assert", "config_entry", ".", "sta...
[ 29, 0 ]
[ 33, 56 ]
python
en
['en', 'en', 'en']
True
test_api_timeout
(hass, config_entry, aioclient_mock)
Test that a timeout results in ConfigEntryNotReady.
Test that a timeout results in ConfigEntryNotReady.
async def test_api_timeout(hass, config_entry, aioclient_mock): """Test that a timeout results in ConfigEntryNotReady.""" await setup_integration(hass, config_entry, aioclient_mock, auth_timeout=True) assert config_entry.state == ENTRY_STATE_SETUP_RETRY
[ "async", "def", "test_api_timeout", "(", "hass", ",", "config_entry", ",", "aioclient_mock", ")", ":", "await", "setup_integration", "(", "hass", ",", "config_entry", ",", "aioclient_mock", ",", "auth_timeout", "=", "True", ")", "assert", "config_entry", ".", "s...
[ 36, 0 ]
[ 40, 56 ]
python
en
['en', 'en', 'en']
True
test_update_failure
(hass, config_entry, aioclient_mock)
Test that the coordinator handles a bad response.
Test that the coordinator handles a bad response.
async def test_update_failure(hass, config_entry, aioclient_mock): """Test that the coordinator handles a bad response.""" await setup_integration(hass, config_entry, aioclient_mock, bad_reading=True) await async_setup_component(hass, HA_DOMAIN, {}) await hass.async_block_till_done() with patch("sma...
[ "async", "def", "test_update_failure", "(", "hass", ",", "config_entry", ",", "aioclient_mock", ")", ":", "await", "setup_integration", "(", "hass", ",", "config_entry", ",", "aioclient_mock", ",", "bad_reading", "=", "True", ")", "await", "async_setup_component", ...
[ 43, 0 ]
[ 56, 36 ]
python
en
['en', 'en', 'en']
True
test_unload_config_entry
(hass, config_entry, aioclient_mock)
Test entry unloading.
Test entry unloading.
async def test_unload_config_entry(hass, config_entry, aioclient_mock): """Test entry unloading.""" await setup_integration(hass, config_entry, aioclient_mock) config_entries = hass.config_entries.async_entries(DOMAIN) assert len(config_entries) == 1 assert config_entries[0] is config_entry ass...
[ "async", "def", "test_unload_config_entry", "(", "hass", ",", "config_entry", ",", "aioclient_mock", ")", ":", "await", "setup_integration", "(", "hass", ",", "config_entry", ",", "aioclient_mock", ")", "config_entries", "=", "hass", ".", "config_entries", ".", "a...
[ 59, 0 ]
[ 71, 55 ]
python
en
['en', 'no', 'en']
True
show_2D
(raw, key_show, GPSA_data_list=None, Z_cut=None, Z_contour=None, key_x='axis0',key_y='axis1', xlim=None, ylim=None, clim=None, ax=None, colorbar=True, cmap='jet', mutiplier=1.0)
if key_x == 'axis0': x = raw[key_x] xx = sorted(list(set(x))) y = raw[key_y] yy = sorted(list(set(y)))
if key_x == 'axis0': x = raw[key_x] xx = sorted(list(set(x))) y = raw[key_y] yy = sorted(list(set(y)))
def show_2D(raw, key_show, GPSA_data_list=None, Z_cut=None, Z_contour=None, key_x='axis0',key_y='axis1', xlim=None, ylim=None, clim=None, ax=None, colorbar=True, cmap='jet', mutiplier=1.0): if ax is None: f, ax = plt.subplot(1,1) """ if key_x == 'axis0': x = raw[key_x] xx = sorted(list(set(x))) y = raw...
[ "def", "show_2D", "(", "raw", ",", "key_show", ",", "GPSA_data_list", "=", "None", ",", "Z_cut", "=", "None", ",", "Z_contour", "=", "None", ",", "key_x", "=", "'axis0'", ",", "key_y", "=", "'axis1'", ",", "xlim", "=", "None", ",", "ylim", "=", "None...
[ 243, 0 ]
[ 329, 10 ]
python
en
['en', 'error', 'th']
False
async_setup
(hass, config)
Initialize the shopping list.
Initialize the shopping list.
async def async_setup(hass, config): """Initialize the shopping list.""" if DOMAIN not in config: return True hass.async_create_task( hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_IMPORT} ) ) return True
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "if", "DOMAIN", "not", "in", "config", ":", "return", "True", "hass", ".", "async_create_task", "(", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "...
[ 56, 0 ]
[ 68, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry)
Set up shopping list from config flow.
Set up shopping list from config flow.
async def async_setup_entry(hass, config_entry): """Set up shopping list from config flow.""" async def add_item_service(call): """Add an item with `name`.""" data = hass.data[DOMAIN] name = call.data.get(ATTR_NAME) if name is not None: await data.async_add(name) ...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ")", ":", "async", "def", "add_item_service", "(", "call", ")", ":", "\"\"\"Add an item with `name`.\"\"\"", "data", "=", "hass", ".", "data", "[", "DOMAIN", "]", "name", "=", "call", ".", ...
[ 71, 0 ]
[ 130, 15 ]
python
en
['en', 'en', 'en']
True
websocket_handle_items
(hass, connection, msg)
Handle get shopping_list items.
Handle get shopping_list items.
def websocket_handle_items(hass, connection, msg): """Handle get shopping_list items.""" connection.send_message( websocket_api.result_message(msg["id"], hass.data[DOMAIN].items) )
[ "def", "websocket_handle_items", "(", "hass", ",", "connection", ",", "msg", ")", ":", "connection", ".", "send_message", "(", "websocket_api", ".", "result_message", "(", "msg", "[", "\"id\"", "]", ",", "hass", ".", "data", "[", "DOMAIN", "]", ".", "items...
[ 240, 0 ]
[ 244, 5 ]
python
en
['nl', 'en', 'en']
True
websocket_handle_add
(hass, connection, msg)
Handle add item to shopping_list.
Handle add item to shopping_list.
async def websocket_handle_add(hass, connection, msg): """Handle add item to shopping_list.""" item = await hass.data[DOMAIN].async_add(msg["name"]) hass.bus.async_fire(EVENT, {"action": "add", "item": item}) connection.send_message(websocket_api.result_message(msg["id"], item))
[ "async", "def", "websocket_handle_add", "(", "hass", ",", "connection", ",", "msg", ")", ":", "item", "=", "await", "hass", ".", "data", "[", "DOMAIN", "]", ".", "async_add", "(", "msg", "[", "\"name\"", "]", ")", "hass", ".", "bus", ".", "async_fire",...
[ 248, 0 ]
[ 252, 74 ]
python
en
['en', 'en', 'en']
True
websocket_handle_update
(hass, connection, msg)
Handle update shopping_list item.
Handle update shopping_list item.
async def websocket_handle_update(hass, connection, msg): """Handle update shopping_list item.""" msg_id = msg.pop("id") item_id = msg.pop("item_id") msg.pop("type") data = msg try: item = await hass.data[DOMAIN].async_update(item_id, data) hass.bus.async_fire(EVENT, {"action": ...
[ "async", "def", "websocket_handle_update", "(", "hass", ",", "connection", ",", "msg", ")", ":", "msg_id", "=", "msg", ".", "pop", "(", "\"id\"", ")", "item_id", "=", "msg", ".", "pop", "(", "\"item_id\"", ")", "msg", ".", "pop", "(", "\"type\"", ")", ...
[ 256, 0 ]
[ 270, 9 ]
python
en
['en', 'en', 'en']
True
websocket_handle_clear
(hass, connection, msg)
Handle clearing shopping_list items.
Handle clearing shopping_list items.
async def websocket_handle_clear(hass, connection, msg): """Handle clearing shopping_list items.""" await hass.data[DOMAIN].async_clear_completed() hass.bus.async_fire(EVENT, {"action": "clear"}) connection.send_message(websocket_api.result_message(msg["id"]))
[ "async", "def", "websocket_handle_clear", "(", "hass", ",", "connection", ",", "msg", ")", ":", "await", "hass", ".", "data", "[", "DOMAIN", "]", ".", "async_clear_completed", "(", ")", "hass", ".", "bus", ".", "async_fire", "(", "EVENT", ",", "{", "\"ac...
[ 274, 0 ]
[ 278, 68 ]
python
en
['en', 'en', 'en']
True
ShoppingData.__init__
(self, hass)
Initialize the shopping list.
Initialize the shopping list.
def __init__(self, hass): """Initialize the shopping list.""" self.hass = hass self.items = []
[ "def", "__init__", "(", "self", ",", "hass", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "items", "=", "[", "]" ]
[ 136, 4 ]
[ 139, 23 ]
python
en
['en', 'en', 'en']
True
ShoppingData.async_add
(self, name)
Add a shopping list item.
Add a shopping list item.
async def async_add(self, name): """Add a shopping list item.""" item = {"name": name, "id": uuid.uuid4().hex, "complete": False} self.items.append(item) await self.hass.async_add_executor_job(self.save) return item
[ "async", "def", "async_add", "(", "self", ",", "name", ")", ":", "item", "=", "{", "\"name\"", ":", "name", ",", "\"id\"", ":", "uuid", ".", "uuid4", "(", ")", ".", "hex", ",", "\"complete\"", ":", "False", "}", "self", ".", "items", ".", "append",...
[ 141, 4 ]
[ 146, 19 ]
python
en
['en', 'cy', 'en']
True
ShoppingData.async_update
(self, item_id, info)
Update a shopping list item.
Update a shopping list item.
async def async_update(self, item_id, info): """Update a shopping list item.""" item = next((itm for itm in self.items if itm["id"] == item_id), None) if item is None: raise KeyError info = ITEM_UPDATE_SCHEMA(info) item.update(info) await self.hass.async_add...
[ "async", "def", "async_update", "(", "self", ",", "item_id", ",", "info", ")", ":", "item", "=", "next", "(", "(", "itm", "for", "itm", "in", "self", ".", "items", "if", "itm", "[", "\"id\"", "]", "==", "item_id", ")", ",", "None", ")", "if", "it...
[ 148, 4 ]
[ 158, 19 ]
python
en
['en', 'lb', 'en']
True
ShoppingData.async_clear_completed
(self)
Clear completed items.
Clear completed items.
async def async_clear_completed(self): """Clear completed items.""" self.items = [itm for itm in self.items if not itm["complete"]] await self.hass.async_add_executor_job(self.save)
[ "async", "def", "async_clear_completed", "(", "self", ")", ":", "self", ".", "items", "=", "[", "itm", "for", "itm", "in", "self", ".", "items", "if", "not", "itm", "[", "\"complete\"", "]", "]", "await", "self", ".", "hass", ".", "async_add_executor_job...
[ 160, 4 ]
[ 163, 57 ]
python
en
['en', 'en', 'en']
True
ShoppingData.async_load
(self)
Load items.
Load items.
async def async_load(self): """Load items.""" def load(): """Load the items synchronously.""" return load_json(self.hass.config.path(PERSISTENCE), default=[]) self.items = await self.hass.async_add_executor_job(load)
[ "async", "def", "async_load", "(", "self", ")", ":", "def", "load", "(", ")", ":", "\"\"\"Load the items synchronously.\"\"\"", "return", "load_json", "(", "self", ".", "hass", ".", "config", ".", "path", "(", "PERSISTENCE", ")", ",", "default", "=", "[", ...
[ 165, 4 ]
[ 172, 65 ]
python
en
['en', 'en', 'en']
False
ShoppingData.save
(self)
Save the items.
Save the items.
def save(self): """Save the items.""" save_json(self.hass.config.path(PERSISTENCE), self.items)
[ "def", "save", "(", "self", ")", ":", "save_json", "(", "self", ".", "hass", ".", "config", ".", "path", "(", "PERSISTENCE", ")", ",", "self", ".", "items", ")" ]
[ 174, 4 ]
[ 176, 65 ]
python
en
['en', 'en', 'en']
True
ShoppingListView.get
(self, request)
Retrieve shopping list items.
Retrieve shopping list items.
def get(self, request): """Retrieve shopping list items.""" return self.json(request.app["hass"].data[DOMAIN].items)
[ "def", "get", "(", "self", ",", "request", ")", ":", "return", "self", ".", "json", "(", "request", ".", "app", "[", "\"hass\"", "]", ".", "data", "[", "DOMAIN", "]", ".", "items", ")" ]
[ 186, 4 ]
[ 188, 64 ]
python
en
['en', 'ga', 'en']
True
UpdateShoppingListItemView.post
(self, request, item_id)
Update a shopping list item.
Update a shopping list item.
async def post(self, request, item_id): """Update a shopping list item.""" data = await request.json() try: item = await request.app["hass"].data[DOMAIN].async_update(item_id, data) request.app["hass"].bus.async_fire(EVENT) return self.json(item) exce...
[ "async", "def", "post", "(", "self", ",", "request", ",", "item_id", ")", ":", "data", "=", "await", "request", ".", "json", "(", ")", "try", ":", "item", "=", "await", "request", ".", "app", "[", "\"hass\"", "]", ".", "data", "[", "DOMAIN", "]", ...
[ 197, 4 ]
[ 208, 72 ]
python
en
['en', 'lb', 'en']
True
CreateShoppingListItemView.post
(self, request, data)
Create a new shopping list item.
Create a new shopping list item.
async def post(self, request, data): """Create a new shopping list item.""" item = await request.app["hass"].data[DOMAIN].async_add(data["name"]) request.app["hass"].bus.async_fire(EVENT) return self.json(item)
[ "async", "def", "post", "(", "self", ",", "request", ",", "data", ")", ":", "item", "=", "await", "request", ".", "app", "[", "\"hass\"", "]", ".", "data", "[", "DOMAIN", "]", ".", "async_add", "(", "data", "[", "\"name\"", "]", ")", "request", "."...
[ 218, 4 ]
[ 222, 30 ]
python
en
['en', 'en', 'en']
True
ClearCompletedItemsView.post
(self, request)
Retrieve if API is running.
Retrieve if API is running.
async def post(self, request): """Retrieve if API is running.""" hass = request.app["hass"] await hass.data[DOMAIN].async_clear_completed() hass.bus.async_fire(EVENT) return self.json_message("Cleared completed items.")
[ "async", "def", "post", "(", "self", ",", "request", ")", ":", "hass", "=", "request", ".", "app", "[", "\"hass\"", "]", "await", "hass", ".", "data", "[", "DOMAIN", "]", ".", "async_clear_completed", "(", ")", "hass", ".", "bus", ".", "async_fire", ...
[ 231, 4 ]
[ 236, 60 ]
python
en
['en', 'sn', 'en']
True
DropPath.__init__
(self, p=0.)
Drop path with probability. Parameters ---------- p : float Probability of an path to be zeroed.
Drop path with probability.
def __init__(self, p=0.): """ Drop path with probability. Parameters ---------- p : float Probability of an path to be zeroed. """ super().__init__() self.p = p
[ "def", "__init__", "(", "self", ",", "p", "=", "0.", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "p", "=", "p" ]
[ 8, 4 ]
[ 18, 18 ]
python
en
['en', 'error', 'th']
False
init
(empty=False)
Initialize the platform with entities.
Initialize the platform with entities.
def init(empty=False): """Initialize the platform with entities.""" global ENTITIES ENTITIES = ( [] if empty else [ MockLight("Ceiling", STATE_ON), MockLight("Ceiling", STATE_OFF), MockLight(None, STATE_OFF), ] )
[ "def", "init", "(", "empty", "=", "False", ")", ":", "global", "ENTITIES", "ENTITIES", "=", "(", "[", "]", "if", "empty", "else", "[", "MockLight", "(", "\"Ceiling\"", ",", "STATE_ON", ")", ",", "MockLight", "(", "\"Ceiling\"", ",", "STATE_OFF", ")", "...
[ 13, 0 ]
[ 25, 5 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
( hass, config, async_add_entities_callback, discovery_info=None )
Return mock entities.
Return mock entities.
async def async_setup_platform( hass, config, async_add_entities_callback, discovery_info=None ): """Return mock entities.""" async_add_entities_callback(ENTITIES)
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities_callback", ",", "discovery_info", "=", "None", ")", ":", "async_add_entities_callback", "(", "ENTITIES", ")" ]
[ 28, 0 ]
[ 32, 41 ]
python
af
['nl', 'af', 'en']
False
AtagConfigFlow.async_step_user
(self, user_input=None)
Handle a flow initialized by the user.
Handle a flow initialized by the user.
async def async_step_user(self, user_input=None): """Handle a flow initialized by the user.""" if not user_input: return await self._show_form() session = async_get_clientsession(self.hass) try: atag = pyatag.AtagOne(session=session, **user_input) awa...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "not", "user_input", ":", "return", "await", "self", ".", "_show_form", "(", ")", "session", "=", "async_get_clientsession", "(", "self", ".", "hass", ")", "try...
[ 23, 4 ]
[ 42, 70 ]
python
en
['en', 'en', 'en']
True
AtagConfigFlow._show_form
(self, errors=None)
Show the form to the user.
Show the form to the user.
async def _show_form(self, errors=None): """Show the form to the user.""" return self.async_show_form( step_id="user", data_schema=vol.Schema(DATA_SCHEMA), errors=errors if errors else {}, )
[ "async", "def", "_show_form", "(", "self", ",", "errors", "=", "None", ")", ":", "return", "self", ".", "async_show_form", "(", "step_id", "=", "\"user\"", ",", "data_schema", "=", "vol", ".", "Schema", "(", "DATA_SCHEMA", ")", ",", "errors", "=", "error...
[ 44, 4 ]
[ 50, 9 ]
python
en
['en', 'en', 'en']
True
setup
(hass, config)
Set up XS1 Component.
Set up XS1 Component.
def setup(hass, config): """Set up XS1 Component.""" _LOGGER.debug("Initializing XS1") host = config[DOMAIN][CONF_HOST] port = config[DOMAIN][CONF_PORT] ssl = config[DOMAIN][CONF_SSL] user = config[DOMAIN].get(CONF_USERNAME) password = config[DOMAIN].get(CONF_PASSWORD) # initialize XS1...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "_LOGGER", ".", "debug", "(", "\"Initializing XS1\"", ")", "host", "=", "config", "[", "DOMAIN", "]", "[", "CONF_HOST", "]", "port", "=", "config", "[", "DOMAIN", "]", "[", "CONF_PORT", "]", "ssl", ...
[ 48, 0 ]
[ 85, 15 ]
python
en
['en', 'fr', 'en']
True
XS1DeviceEntity.__init__
(self, device)
Initialize the XS1 device.
Initialize the XS1 device.
def __init__(self, device): """Initialize the XS1 device.""" self.device = device
[ "def", "__init__", "(", "self", ",", "device", ")", ":", "self", ".", "device", "=", "device" ]
[ 91, 4 ]
[ 93, 28 ]
python
en
['en', 'en', 'en']
True
XS1DeviceEntity.async_update
(self)
Retrieve latest device state.
Retrieve latest device state.
async def async_update(self): """Retrieve latest device state.""" async with UPDATE_LOCK: await self.hass.async_add_executor_job(self.device.update)
[ "async", "def", "async_update", "(", "self", ")", ":", "async", "with", "UPDATE_LOCK", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "device", ".", "update", ")" ]
[ 95, 4 ]
[ 98, 70 ]
python
en
['fr', 'ro', 'en']
False
OAuth2FlowHandler.logger
(self)
Return logger.
Return logger.
def logger(self) -> logging.Logger: """Return logger.""" return logging.getLogger(__name__)
[ "def", "logger", "(", "self", ")", "->", "logging", ".", "Logger", ":", "return", "logging", ".", "getLogger", "(", "__name__", ")" ]
[ 19, 4 ]
[ 21, 42 ]
python
en
['es', 'no', 'en']
False
compress_raw
(raw)
print 'before compression: '+str(n)+' points' print 'after compression: '+str(len(ii))+' points' plt.plot(x, T, marker='.') plt.plot([x[i] for i in ii], [T[i] for i in ii], marker='o', fillstyle='none') plt.show()
print 'before compression: '+str(n)+' points' print 'after compression: '+str(len(ii))+' points'
def compress_raw(raw): x = raw['axis0'] T = raw['temperature'] n = len(x) i_ign = n-1 for i in range(n): if T[i] >= T[0] + 400: i_ign = i break dx = 1.0*x[i_ign]/10 ii = [0] for i in range(1, n): if x[i]-x[ii[-1]] >= dx or T[i]-T[ii[-1]]>50: ii.append(i) raw_c = dict() for k in raw.keys(): ...
[ "def", "compress_raw", "(", "raw", ")", ":", "x", "=", "raw", "[", "'axis0'", "]", "T", "=", "raw", "[", "'temperature'", "]", "n", "=", "len", "(", "x", ")", "i_ign", "=", "n", "-", "1", "for", "i", "in", "range", "(", "n", ")", ":", "if", ...
[ 188, 0 ]
[ 231, 4 ]
python
en
['en', 'error', 'th']
False
get_device
(name)
Get a device by name.
Get a device by name.
def get_device(name): """Get a device by name.""" return BroadlinkDevice(name, *BROADLINK_DEVICES[name])
[ "def", "get_device", "(", "name", ")", ":", "return", "BroadlinkDevice", "(", "name", ",", "*", "BROADLINK_DEVICES", "[", "name", "]", ")" ]
[ 141, 0 ]
[ 143, 58 ]
python
en
['en', 'en', 'en']
True
BroadlinkDevice.__init__
( self, name, host, mac, model, manufacturer, type_, devtype, fwversion, timeout )
Initialize the device.
Initialize the device.
def __init__( self, name, host, mac, model, manufacturer, type_, devtype, fwversion, timeout ): """Initialize the device.""" self.name: str = name self.host: str = host self.mac: str = mac self.model: str = model self.manufacturer: str = manufacturer s...
[ "def", "__init__", "(", "self", ",", "name", ",", "host", ",", "mac", ",", "model", ",", "manufacturer", ",", "type_", ",", "devtype", ",", "fwversion", ",", "timeout", ")", ":", "self", ".", "name", ":", "str", "=", "name", "self", ".", "host", ":...
[ 74, 4 ]
[ 86, 39 ]
python
en
['en', 'en', 'en']
True
BroadlinkDevice.setup_entry
(self, hass, mock_api=None, mock_entry=None)
Set up the device.
Set up the device.
async def setup_entry(self, hass, mock_api=None, mock_entry=None): """Set up the device.""" mock_api = mock_api or self.get_mock_api() mock_entry = mock_entry or self.get_mock_entry() mock_entry.add_to_hass(hass) with patch( "homeassistant.components.broadlink.device...
[ "async", "def", "setup_entry", "(", "self", ",", "hass", ",", "mock_api", "=", "None", ",", "mock_entry", "=", "None", ")", ":", "mock_api", "=", "mock_api", "or", "self", ".", "get_mock_api", "(", ")", "mock_entry", "=", "mock_entry", "or", "self", ".",...
[ 88, 4 ]
[ 104, 35 ]
python
en
['en', 'en', 'en']
True
BroadlinkDevice.get_mock_api
(self)
Return a mock device (API).
Return a mock device (API).
def get_mock_api(self): """Return a mock device (API).""" mock_api = MagicMock() mock_api.name = self.name mock_api.host = (self.host, 80) mock_api.mac = bytes.fromhex(self.mac) mock_api.model = self.model mock_api.manufacturer = self.manufacturer mock_api...
[ "def", "get_mock_api", "(", "self", ")", ":", "mock_api", "=", "MagicMock", "(", ")", "mock_api", ".", "name", "=", "self", ".", "name", "mock_api", ".", "host", "=", "(", "self", ".", "host", ",", "80", ")", "mock_api", ".", "mac", "=", "bytes", "...
[ 106, 4 ]
[ 120, 23 ]
python
en
['es', 'haw', 'en']
False
BroadlinkDevice.get_mock_entry
(self)
Return a mock config entry.
Return a mock config entry.
def get_mock_entry(self): """Return a mock config entry.""" return MockConfigEntry( domain=DOMAIN, unique_id=self.mac, title=self.name, data=self.get_entry_data(), )
[ "def", "get_mock_entry", "(", "self", ")", ":", "return", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "unique_id", "=", "self", ".", "mac", ",", "title", "=", "self", ".", "name", ",", "data", "=", "self", ".", "get_entry_data", "(", ")", ","...
[ 122, 4 ]
[ 129, 9 ]
python
en
['en', 'cy', 'en']
True
BroadlinkDevice.get_entry_data
(self)
Return entry data.
Return entry data.
def get_entry_data(self): """Return entry data.""" return { "host": self.host, "mac": self.mac, "type": self.devtype, "timeout": self.timeout, }
[ "def", "get_entry_data", "(", "self", ")", ":", "return", "{", "\"host\"", ":", "self", ".", "host", ",", "\"mac\"", ":", "self", ".", "mac", ",", "\"type\"", ":", "self", ".", "devtype", ",", "\"timeout\"", ":", "self", ".", "timeout", ",", "}" ]
[ 131, 4 ]
[ 138, 9 ]
python
en
['en', 'no', 'en']
True
FSMTTokenizationTest.test_online_tokenizer_config
(self)
this just tests that the online tokenizer files get correctly fetched and loaded via its tokenizer_config.json and it's not slow so it's run by normal CI
this just tests that the online tokenizer files get correctly fetched and loaded via its tokenizer_config.json and it's not slow so it's run by normal CI
def test_online_tokenizer_config(self): """this just tests that the online tokenizer files get correctly fetched and loaded via its tokenizer_config.json and it's not slow so it's run by normal CI """ tokenizer = FSMTTokenizer.from_pretrained(FSMT_TINY2) self.assertListEqual([tok...
[ "def", "test_online_tokenizer_config", "(", "self", ")", ":", "tokenizer", "=", "FSMTTokenizer", ".", "from_pretrained", "(", "FSMT_TINY2", ")", "self", ".", "assertListEqual", "(", "[", "tokenizer", ".", "src_lang", ",", "tokenizer", ".", "tgt_lang", "]", ",", ...
[ 92, 4 ]
[ 99, 54 ]
python
en
['en', 'en', 'en']
True
FSMTTokenizationTest.test_full_tokenizer
(self)
Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
def test_full_tokenizer(self): """ Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt """ tokenizer = FSMTTokenizer(self.langs, self.src_vocab_file, self.tgt_vocab_file, self.merges_file) text = "lower" bpe_tokens = ["low", "er</w>"] tokens = tokenize...
[ "def", "test_full_tokenizer", "(", "self", ")", ":", "tokenizer", "=", "FSMTTokenizer", "(", "self", ".", "langs", ",", "self", ".", "src_vocab_file", ",", "self", ".", "tgt_vocab_file", ",", "self", ".", "merges_file", ")", "text", "=", "\"lower\"", "bpe_to...
[ 101, 4 ]
[ 112, 93 ]
python
en
['en', 'no', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the TCP Sensor.
Set up the TCP Sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the TCP Sensor.""" add_entities([TcpSensor(hass, config)])
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "add_entities", "(", "[", "TcpSensor", "(", "hass", ",", "config", ")", "]", ")" ]
[ 45, 0 ]
[ 47, 43 ]
python
en
['en', 'sq', 'en']
True
TcpSensor.__init__
(self, hass, config)
Set all the config values if they exist and get initial state.
Set all the config values if they exist and get initial state.
def __init__(self, hass, config): """Set all the config values if they exist and get initial state.""" value_template = config.get(CONF_VALUE_TEMPLATE) if value_template is not None: value_template.hass = hass self._hass = hass self._config = { CONF_NAME...
[ "def", "__init__", "(", "self", ",", "hass", ",", "config", ")", ":", "value_template", "=", "config", ".", "get", "(", "CONF_VALUE_TEMPLATE", ")", "if", "value_template", "is", "not", "None", ":", "value_template", ".", "hass", "=", "hass", "self", ".", ...
[ 55, 4 ]
[ 75, 21 ]
python
en
['en', 'en', 'en']
True
TcpSensor.name
(self)
Return the name of this sensor.
Return the name of this sensor.
def name(self): """Return the name of this sensor.""" name = self._config[CONF_NAME] if name is not None: return name return super().name
[ "def", "name", "(", "self", ")", ":", "name", "=", "self", ".", "_config", "[", "CONF_NAME", "]", "if", "name", "is", "not", "None", ":", "return", "name", "return", "super", "(", ")", ".", "name" ]
[ 78, 4 ]
[ 83, 27 ]
python
en
['en', 'mi', 'en']
True
TcpSensor.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 86, 4 ]
[ 88, 26 ]
python
en
['en', 'en', 'en']
True
TcpSensor.unit_of_measurement
(self)
Return the unit of measurement of this entity.
Return the unit of measurement of this entity.
def unit_of_measurement(self): """Return the unit of measurement of this entity.""" return self._config[CONF_UNIT_OF_MEASUREMENT]
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_config", "[", "CONF_UNIT_OF_MEASUREMENT", "]" ]
[ 91, 4 ]
[ 93, 53 ]
python
en
['en', 'en', 'en']
True
TcpSensor.update
(self)
Get the latest value for this sensor.
Get the latest value for this sensor.
def update(self): """Get the latest value for this sensor.""" with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: sock.settimeout(self._config[CONF_TIMEOUT]) try: sock.connect((self._config[CONF_HOST], self._config[CONF_PORT])) except OSErr...
[ "def", "update", "(", "self", ")", ":", "with", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "as", "sock", ":", "sock", ".", "settimeout", "(", "self", ".", "_config", "[", "CONF_TIMEOUT", "]", ")", ...
[ 95, 4 ]
[ 150, 27 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Raspberry PI GPIO devices.
Set up the Raspberry PI GPIO devices.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Raspberry PI GPIO devices.""" address = config["host"] invert_logic = config[CONF_INVERT_LOGIC] pull_mode = config[CONF_PULL_MODE] ports = config["ports"] bouncetime = config[CONF_BOUNCETIME] / 1000 devices =...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "address", "=", "config", "[", "\"host\"", "]", "invert_logic", "=", "config", "[", "CONF_INVERT_LOGIC", "]", "pull_mode", "=", "config", ...
[ 33, 0 ]
[ 52, 31 ]
python
en
['en', 'sr', 'en']
True
RemoteRPiGPIOBinarySensor.__init__
(self, name, button, invert_logic)
Initialize the RPi binary sensor.
Initialize the RPi binary sensor.
def __init__(self, name, button, invert_logic): """Initialize the RPi binary sensor.""" self._name = name self._invert_logic = invert_logic self._state = False self._button = button
[ "def", "__init__", "(", "self", ",", "name", ",", "button", ",", "invert_logic", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_invert_logic", "=", "invert_logic", "self", ".", "_state", "=", "False", "self", ".", "_button", "=", "button" ]
[ 58, 4 ]
[ 63, 29 ]
python
en
['en', 'pt', 'en']
True
RemoteRPiGPIOBinarySensor.async_added_to_hass
(self)
Run when entity about to be added to hass.
Run when entity about to be added to hass.
async def async_added_to_hass(self): """Run when entity about to be added to hass.""" def read_gpio(): """Read state from GPIO.""" self._state = remote_rpi_gpio.read_input(self._button) self.schedule_update_ha_state() self._button.when_released = read_gpio ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "def", "read_gpio", "(", ")", ":", "\"\"\"Read state from GPIO.\"\"\"", "self", ".", "_state", "=", "remote_rpi_gpio", ".", "read_input", "(", "self", ".", "_button", ")", "self", ".", "schedule_updat...
[ 65, 4 ]
[ 74, 45 ]
python
en
['en', 'en', 'en']
True
RemoteRPiGPIOBinarySensor.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 77, 4 ]
[ 79, 20 ]
python
en
['en', 'en', 'en']
True
RemoteRPiGPIOBinarySensor.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" ]
[ 82, 4 ]
[ 84, 25 ]
python
en
['en', 'mi', 'en']
True
RemoteRPiGPIOBinarySensor.is_on
(self)
Return the state of the entity.
Return the state of the entity.
def is_on(self): """Return the state of the entity.""" return self._state != self._invert_logic
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state", "!=", "self", ".", "_invert_logic" ]
[ 87, 4 ]
[ 89, 48 ]
python
en
['en', 'en', 'en']
True
RemoteRPiGPIOBinarySensor.device_class
(self)
Return the class of this sensor, from DEVICE_CLASSES.
Return the class of this sensor, from DEVICE_CLASSES.
def device_class(self): """Return the class of this sensor, from DEVICE_CLASSES.""" return
[ "def", "device_class", "(", "self", ")", ":", "return" ]
[ 92, 4 ]
[ 94, 14 ]
python
en
['en', 'en', 'en']
True
RemoteRPiGPIOBinarySensor.update
(self)
Update the GPIO state.
Update the GPIO state.
def update(self): """Update the GPIO state.""" try: self._state = remote_rpi_gpio.read_input(self._button) except requests.exceptions.ConnectionError: return
[ "def", "update", "(", "self", ")", ":", "try", ":", "self", ".", "_state", "=", "remote_rpi_gpio", ".", "read_input", "(", "self", ".", "_button", ")", "except", "requests", ".", "exceptions", ".", "ConnectionError", ":", "return" ]
[ 96, 4 ]
[ 101, 18 ]
python
en
['en', 'it', 'en']
True
setup
(hass, config)
Set up the Mycroft component.
Set up the Mycroft component.
def setup(hass, config): """Set up the Mycroft component.""" hass.data[DOMAIN] = config[DOMAIN][CONF_HOST] discovery.load_platform(hass, "notify", DOMAIN, {}, config) return True
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "config", "[", "DOMAIN", "]", "[", "CONF_HOST", "]", "discovery", ".", "load_platform", "(", "hass", ",", "\"notify\"", ",", "DOMAIN", ",", "{", "}", ...
[ 14, 0 ]
[ 18, 15 ]
python
en
['en', 'fr', 'en']
True
_get_deconz_event_from_device_id
(hass, device_id)
Resolve deconz event from device id.
Resolve deconz event from device id.
def _get_deconz_event_from_device_id(hass, device_id): """Resolve deconz event from device id.""" for gateway in hass.data.get(DOMAIN, {}).values(): for deconz_event in gateway.events: if device_id == deconz_event.device_id: return deconz_event return None
[ "def", "_get_deconz_event_from_device_id", "(", "hass", ",", "device_id", ")", ":", "for", "gateway", "in", "hass", ".", "data", ".", "get", "(", "DOMAIN", ",", "{", "}", ")", ".", "values", "(", ")", ":", "for", "deconz_event", "in", "gateway", ".", "...
[ 393, 0 ]
[ 402, 15 ]
python
en
['en', 'en', 'en']
True
async_validate_trigger_config
(hass, config)
Validate config.
Validate config.
async def async_validate_trigger_config(hass, config): """Validate config.""" config = TRIGGER_SCHEMA(config) device_registry = await hass.helpers.device_registry.async_get_registry() device = device_registry.async_get(config[CONF_DEVICE_ID]) trigger = (config[CONF_TYPE], config[CONF_SUBTYPE]) ...
[ "async", "def", "async_validate_trigger_config", "(", "hass", ",", "config", ")", ":", "config", "=", "TRIGGER_SCHEMA", "(", "config", ")", "device_registry", "=", "await", "hass", ".", "helpers", ".", "device_registry", ".", "async_get_registry", "(", ")", "dev...
[ 405, 0 ]
[ 421, 17 ]
python
en
['en', 'la', 'it']
False
async_attach_trigger
(hass, config, action, automation_info)
Listen for state changes based on configuration.
Listen for state changes based on configuration.
async def async_attach_trigger(hass, config, action, automation_info): """Listen for state changes based on configuration.""" device_registry = await hass.helpers.device_registry.async_get_registry() device = device_registry.async_get(config[CONF_DEVICE_ID]) trigger = (config[CONF_TYPE], config[CONF_SU...
[ "async", "def", "async_attach_trigger", "(", "hass", ",", "config", ",", "action", ",", "automation_info", ")", ":", "device_registry", "=", "await", "hass", ".", "helpers", ".", "device_registry", ".", "async_get_registry", "(", ")", "device", "=", "device_regi...
[ 424, 0 ]
[ 449, 5 ]
python
en
['en', 'en', 'en']
True
async_get_triggers
(hass, device_id)
List device triggers. Make sure device is a supported remote model. Retrieve the deconz event object matching device entry. Generate device trigger list.
List device triggers.
async def async_get_triggers(hass, device_id): """List device triggers. Make sure device is a supported remote model. Retrieve the deconz event object matching device entry. Generate device trigger list. """ device_registry = await hass.helpers.device_registry.async_get_registry() device = ...
[ "async", "def", "async_get_triggers", "(", "hass", ",", "device_id", ")", ":", "device_registry", "=", "await", "hass", ".", "helpers", ".", "device_registry", ".", "async_get_registry", "(", ")", "device", "=", "device_registry", ".", "async_get", "(", "device_...
[ 452, 0 ]
[ 477, 19 ]
python
en
['fr', 'en', 'en']
True
Callback.build
(self, model, mutator, trainer)
Callback needs to be built with model, mutator, trainer, to get updates from them. Parameters ---------- model : nn.Module Model to be trained. mutator : nn.Module Mutator that mutates the model. trainer : BaseTrainer Trainer that is ...
Callback needs to be built with model, mutator, trainer, to get updates from them.
def build(self, model, mutator, trainer): """ Callback needs to be built with model, mutator, trainer, to get updates from them. Parameters ---------- model : nn.Module Model to be trained. mutator : nn.Module Mutator that mutates the model. ...
[ "def", "build", "(", "self", ",", "model", ",", "mutator", ",", "trainer", ")", ":", "self", ".", "model", "=", "model", "self", ".", "mutator", "=", "mutator", "self", ".", "trainer", "=", "trainer" ]
[ 22, 4 ]
[ 37, 30 ]
python
en
['en', 'error', 'th']
False
Callback.on_epoch_begin
(self, epoch)
Implement this to do something at the begin of epoch. Parameters ---------- epoch : int Epoch number, starting from 0.
Implement this to do something at the begin of epoch.
def on_epoch_begin(self, epoch): """ Implement this to do something at the begin of epoch. Parameters ---------- epoch : int Epoch number, starting from 0. """ pass
[ "def", "on_epoch_begin", "(", "self", ",", "epoch", ")", ":", "pass" ]
[ 39, 4 ]
[ 48, 12 ]
python
en
['en', 'error', 'th']
False
Callback.on_epoch_end
(self, epoch)
Implement this to do something at the end of epoch. Parameters ---------- epoch : int Epoch number, starting from 0.
Implement this to do something at the end of epoch.
def on_epoch_end(self, epoch): """ Implement this to do something at the end of epoch. Parameters ---------- epoch : int Epoch number, starting from 0. """ pass
[ "def", "on_epoch_end", "(", "self", ",", "epoch", ")", ":", "pass" ]
[ 50, 4 ]
[ 59, 12 ]
python
en
['en', 'error', 'th']
False
LRSchedulerCallback.on_epoch_end
(self, epoch)
Call ``self.scheduler.step()`` on epoch end.
Call ``self.scheduler.step()`` on epoch end.
def on_epoch_end(self, epoch): """ Call ``self.scheduler.step()`` on epoch end. """ self.scheduler.step()
[ "def", "on_epoch_end", "(", "self", ",", "epoch", ")", ":", "self", ".", "scheduler", ".", "step", "(", ")" ]
[ 83, 4 ]
[ 87, 29 ]
python
en
['en', 'error', 'th']
False
ArchitectureCheckpoint.on_epoch_end
(self, epoch)
Dump to ``/checkpoint_dir/epoch_{number}.json`` on epoch end.
Dump to ``/checkpoint_dir/epoch_{number}.json`` on epoch end.
def on_epoch_end(self, epoch): """ Dump to ``/checkpoint_dir/epoch_{number}.json`` on epoch end. """ dest_path = os.path.join(self.checkpoint_dir, "epoch_{}.json".format(epoch)) _logger.info("Saving architecture to %s", dest_path) self.trainer.export(dest_path)
[ "def", "on_epoch_end", "(", "self", ",", "epoch", ")", ":", "dest_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "checkpoint_dir", ",", "\"epoch_{}.json\"", ".", "format", "(", "epoch", ")", ")", "_logger", ".", "info", "(", "\"Saving arch...
[ 104, 4 ]
[ 110, 38 ]
python
en
['en', 'error', 'th']
False
ModelCheckpoint.on_epoch_end
(self, epoch)
Dump to ``/checkpoint_dir/epoch_{number}.pth.tar`` on every epoch end. ``DataParallel`` object will have their inside modules exported.
Dump to ``/checkpoint_dir/epoch_{number}.pth.tar`` on every epoch end. ``DataParallel`` object will have their inside modules exported.
def on_epoch_end(self, epoch): """ Dump to ``/checkpoint_dir/epoch_{number}.pth.tar`` on every epoch end. ``DataParallel`` object will have their inside modules exported. """ if isinstance(self.model, nn.DataParallel): state_dict = self.model.module.state_dict() ...
[ "def", "on_epoch_end", "(", "self", ",", "epoch", ")", ":", "if", "isinstance", "(", "self", ".", "model", ",", "nn", ".", "DataParallel", ")", ":", "state_dict", "=", "self", ".", "model", ".", "module", ".", "state_dict", "(", ")", "else", ":", "st...
[ 127, 4 ]
[ 138, 41 ]
python
en
['en', 'error', 'th']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the IHC lights platform.
Set up the IHC lights platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the IHC lights platform.""" if discovery_info is None: return devices = [] for name, device in discovery_info.items(): ihc_id = device["ihc_id"] product_cfg = device["product_cfg"] product = de...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "devices", "=", "[", "]", "for", "name", ",", "device", "in", "discovery_info", "."...
[ 13, 0 ]
[ 34, 25 ]
python
en
['en', 'lv', 'en']
True
IhcLight.__init__
( self, ihc_controller, name, ihc_id: int, ihc_off_id: int, ihc_on_id: int, info: bool, dimmable=False, product=None, )
Initialize the light.
Initialize the light.
def __init__( self, ihc_controller, name, ihc_id: int, ihc_off_id: int, ihc_on_id: int, info: bool, dimmable=False, product=None, ) -> None: """Initialize the light.""" super().__init__(ihc_controller, name, ihc_id, info, produc...
[ "def", "__init__", "(", "self", ",", "ihc_controller", ",", "name", ",", "ihc_id", ":", "int", ",", "ihc_off_id", ":", "int", ",", "ihc_on_id", ":", "int", ",", "info", ":", "bool", ",", "dimmable", "=", "False", ",", "product", "=", "None", ",", ")"...
[ 45, 4 ]
[ 62, 26 ]
python
en
['en', 'en', 'en']
True
IhcLight.brightness
(self)
Return the brightness of this light between 0..255.
Return the brightness of this light between 0..255.
def brightness(self) -> int: """Return the brightness of this light between 0..255.""" return self._brightness
[ "def", "brightness", "(", "self", ")", "->", "int", ":", "return", "self", ".", "_brightness" ]
[ 65, 4 ]
[ 67, 31 ]
python
en
['en', 'en', 'en']
True
IhcLight.is_on
(self)
Return true if light is on.
Return true if light is on.
def is_on(self) -> bool: """Return true if light is on.""" return self._state
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_state" ]
[ 70, 4 ]
[ 72, 26 ]
python
en
['en', 'et', 'en']
True
IhcLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" if self._dimmable: return SUPPORT_BRIGHTNESS return 0
[ "def", "supported_features", "(", "self", ")", ":", "if", "self", ".", "_dimmable", ":", "return", "SUPPORT_BRIGHTNESS", "return", "0" ]
[ 75, 4 ]
[ 79, 16 ]
python
en
['da', 'en', 'en']
True
IhcLight.async_turn_on
(self, **kwargs)
Turn the light on.
Turn the light on.
async def async_turn_on(self, **kwargs): """Turn the light on.""" if ATTR_BRIGHTNESS in kwargs: brightness = kwargs[ATTR_BRIGHTNESS] else: brightness = self._brightness if brightness == 0: brightness = 255 if self._dimmable: ...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "ATTR_BRIGHTNESS", "in", "kwargs", ":", "brightness", "=", "kwargs", "[", "ATTR_BRIGHTNESS", "]", "else", ":", "brightness", "=", "self", ".", "_brightness", "if", "brig...
[ 81, 4 ]
[ 98, 87 ]
python
en
['en', 'et', 'en']
True
IhcLight.async_turn_off
(self, **kwargs)
Turn the light off.
Turn the light off.
async def async_turn_off(self, **kwargs): """Turn the light off.""" if self._dimmable: await async_set_int(self.hass, self.ihc_controller, self.ihc_id, 0) else: if self._ihc_off_id: await async_pulse(self.hass, self.ihc_controller, self._ihc_off_id) ...
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_dimmable", ":", "await", "async_set_int", "(", "self", ".", "hass", ",", "self", ".", "ihc_controller", ",", "self", ".", "ihc_id", ",", "0", ")", ...
[ 100, 4 ]
[ 108, 88 ]
python
en
['en', 'zh', 'en']
True
IhcLight.on_ihc_change
(self, ihc_id, value)
Handle IHC notifications.
Handle IHC notifications.
def on_ihc_change(self, ihc_id, value): """Handle IHC notifications.""" if isinstance(value, bool): self._dimmable = False self._state = value != 0 else: self._dimmable = True self._state = value > 0 if self._state: self...
[ "def", "on_ihc_change", "(", "self", ",", "ihc_id", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "bool", ")", ":", "self", ".", "_dimmable", "=", "False", "self", ".", "_state", "=", "value", "!=", "0", "else", ":", "self", ".", "...
[ 110, 4 ]
[ 120, 39 ]
python
en
['en', 'xh', 'en']
True
async_setup
(hass: HomeAssistant, config: dict)
Set up the Flick Electric component.
Set up the Flick Electric component.
async def async_setup(hass: HomeAssistant, config: dict): """Set up the Flick Electric component.""" hass.data[DOMAIN] = {} return True
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "dict", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "}", "return", "True" ]
[ 24, 0 ]
[ 27, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up Flick Electric from a config entry.
Set up Flick Electric from a config entry.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Flick Electric from a config entry.""" auth = HassFlickAuth(hass, entry) hass.data[DOMAIN][entry.entry_id] = FlickAPI(auth) hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry, "sensor") ...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "auth", "=", "HassFlickAuth", "(", "hass", ",", "entry", ")", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]",...
[ 30, 0 ]
[ 40, 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.""" if await hass.config_entries.async_forward_entry_unload(entry, "sensor"): hass.data[DOMAIN].pop(entry.entry_id) return True return False
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "if", "await", "hass", ".", "config_entries", ".", "async_forward_entry_unload", "(", "entry", ",", "\"sensor\"", ")", ":", "hass", ".", "data"...
[ 43, 0 ]
[ 49, 16 ]
python
en
['en', 'es', 'en']
True
HassFlickAuth.__init__
(self, hass: HomeAssistant, entry: ConfigEntry)
Flick authention based on a Home Assistant entity config.
Flick authention based on a Home Assistant entity config.
def __init__(self, hass: HomeAssistant, entry: ConfigEntry): """Flick authention based on a Home Assistant entity config.""" super().__init__(aiohttp_client.async_get_clientsession(hass)) self._entry = entry self._hass = hass
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "super", "(", ")", ".", "__init__", "(", "aiohttp_client", ".", "async_get_clientsession", "(", "hass", ")", ")", "self", ".", "_entry", "=", "...
[ 55, 4 ]
[ 59, 25 ]
python
en
['en', 'en', 'en']
True
HassFlickAuth.async_get_access_token
(self)
Get Access Token from HASS Storage.
Get Access Token from HASS Storage.
async def async_get_access_token(self): """Get Access Token from HASS Storage.""" token = await self._get_entry_token() return token[CONF_ID_TOKEN]
[ "async", "def", "async_get_access_token", "(", "self", ")", ":", "token", "=", "await", "self", ".", "_get_entry_token", "(", ")", "return", "token", "[", "CONF_ID_TOKEN", "]" ]
[ 97, 4 ]
[ 101, 35 ]
python
en
['en', 'en', 'en']
True
Order.__init__
(self, tick: int, src_port_idx: int, dest_port_idx: int, quantity: int)
Create a new instants of order Args: tick (int): Generated tick of current order. src_port_idx (int): Source port of this order. dest_port_idx (int): Destination port id of this order. quantity (int): Container quantity of this order.
Create a new instants of order
def __init__(self, tick: int, src_port_idx: int, dest_port_idx: int, quantity: int): """ Create a new instants of order Args: tick (int): Generated tick of current order. src_port_idx (int): Source port of this order. dest_port_idx (int): Destination port id ...
[ "def", "__init__", "(", "self", ",", "tick", ":", "int", ",", "src_port_idx", ":", "int", ",", "dest_port_idx", ":", "int", ",", "quantity", ":", "int", ")", ":", "self", ".", "tick", "=", "tick", "self", ".", "src_port_idx", "=", "src_port_idx", "self...
[ 92, 4 ]
[ 105, 42 ]
python
en
['en', 'error', 'th']
False
mock_debugpy
()
Mock debugpy lib.
Mock debugpy lib.
def mock_debugpy(): """Mock debugpy lib.""" with patch("homeassistant.components.debugpy.debugpy") as mocked_debugpy: yield mocked_debugpy
[ "def", "mock_debugpy", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.debugpy.debugpy\"", ")", "as", "mocked_debugpy", ":", "yield", "mocked_debugpy" ]
[ 18, 0 ]
[ 21, 28 ]
python
es
['es', 'so', 'pt']
False
test_default
(hass: HomeAssistant, mock_debugpy)
Test if the default settings work.
Test if the default settings work.
async def test_default(hass: HomeAssistant, mock_debugpy) -> None: """Test if the default settings work.""" assert await async_setup_component(hass, DOMAIN, {DOMAIN: {}}) mock_debugpy.listen.assert_called_once_with(("0.0.0.0", 5678)) mock_debugpy.wait_for_client.assert_not_called() assert len(mock_...
[ "async", "def", "test_default", "(", "hass", ":", "HomeAssistant", ",", "mock_debugpy", ")", "->", "None", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "}", "}", ")", "mock_debugpy", ".", "liste...
[ 24, 0 ]
[ 30, 46 ]
python
en
['en', 'en', 'en']
True
test_wait_on_startup
(hass: HomeAssistant, mock_debugpy)
Test if the waiting for client is called.
Test if the waiting for client is called.
async def test_wait_on_startup(hass: HomeAssistant, mock_debugpy) -> None: """Test if the waiting for client is called.""" assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_WAIT: True}}) mock_debugpy.listen.assert_called_once_with(("0.0.0.0", 5678)) mock_debugpy.wait_for_client.assert_cal...
[ "async", "def", "test_wait_on_startup", "(", "hass", ":", "HomeAssistant", ",", "mock_debugpy", ")", "->", "None", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "CONF_WAIT", ":", "True", "}", "}", ...
[ 33, 0 ]
[ 39, 46 ]
python
en
['en', 'en', 'en']
True
test_on_demand
(hass: HomeAssistant, mock_debugpy)
Test on-demand debugging using a service call.
Test on-demand debugging using a service call.
async def test_on_demand(hass: HomeAssistant, mock_debugpy) -> None: """Test on-demand debugging using a service call.""" assert await async_setup_component( hass, DOMAIN, {DOMAIN: {CONF_START: False, CONF_HOST: "127.0.0.1", CONF_PORT: 80}}, ) mock_debugpy.listen.assert_not_call...
[ "async", "def", "test_on_demand", "(", "hass", ":", "HomeAssistant", ",", "mock_debugpy", ")", "->", "None", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "CONF_START", ":", "False", ",", "CONF_HOS...
[ 42, 0 ]
[ 62, 46 ]
python
en
['en', 'en', 'en']
True
config_entry_fixture
()
Create a mock HEOS config entry.
Create a mock HEOS config entry.
def config_entry_fixture(): """Create a mock HEOS config entry.""" return MockConfigEntry( domain=DOMAIN, data={CONF_HOST: "127.0.0.1"}, title="Controller (127.0.0.1)" )
[ "def", "config_entry_fixture", "(", ")", ":", "return", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "{", "CONF_HOST", ":", "\"127.0.0.1\"", "}", ",", "title", "=", "\"Controller (127.0.0.1)\"", ")" ]
[ 15, 0 ]
[ 19, 5 ]
python
en
['en', 'gl', 'en']
True
controller_fixture
( players, favorites, input_sources, playlists, change_data, dispatcher )
Create a mock Heos controller fixture.
Create a mock Heos controller fixture.
def controller_fixture( players, favorites, input_sources, playlists, change_data, dispatcher ): """Create a mock Heos controller fixture.""" mock_heos = Mock(Heos) for player in players.values(): player.heos = mock_heos mock_heos.dispatcher = dispatcher mock_heos.get_players.return_valu...
[ "def", "controller_fixture", "(", "players", ",", "favorites", ",", "input_sources", ",", "playlists", ",", "change_data", ",", "dispatcher", ")", ":", "mock_heos", "=", "Mock", "(", "Heos", ")", "for", "player", "in", "players", ".", "values", "(", ")", "...
[ 23, 0 ]
[ 45, 23 ]
python
en
['es', 'gl', 'en']
False
config_fixture
()
Create hass config fixture.
Create hass config fixture.
def config_fixture(): """Create hass config fixture.""" return {DOMAIN: {CONF_HOST: "127.0.0.1"}}
[ "def", "config_fixture", "(", ")", ":", "return", "{", "DOMAIN", ":", "{", "CONF_HOST", ":", "\"127.0.0.1\"", "}", "}" ]
[ 49, 0 ]
[ 51, 45 ]
python
en
['en', 'en', 'en']
True
player_fixture
(quick_selects)
Create a mock HeosPlayer.
Create a mock HeosPlayer.
def player_fixture(quick_selects): """Create a mock HeosPlayer.""" player = Mock(HeosPlayer) player.player_id = 1 player.name = "Test Player" player.model = "Test Model" player.version = "1.0.0" player.is_muted = False player.available = True player.state = const.PLAY_STATE_STOP ...
[ "def", "player_fixture", "(", "quick_selects", ")", ":", "player", "=", "Mock", "(", "HeosPlayer", ")", "player", ".", "player_id", "=", "1", "player", ".", "name", "=", "\"Test Player\"", "player", ".", "model", "=", "\"Test Model\"", "player", ".", "versio...
[ 55, 0 ]
[ 84, 37 ]
python
en
['en', 'ig', 'en']
True
favorites_fixture
()
Create favorites fixture.
Create favorites fixture.
def favorites_fixture() -> Dict[int, HeosSource]: """Create favorites fixture.""" station = Mock(HeosSource) station.type = const.TYPE_STATION station.name = "Today's Hits Radio" station.media_id = "123456789" radio = Mock(HeosSource) radio.type = const.TYPE_STATION radio.name = "Classic...
[ "def", "favorites_fixture", "(", ")", "->", "Dict", "[", "int", ",", "HeosSource", "]", ":", "station", "=", "Mock", "(", "HeosSource", ")", "station", ".", "type", "=", "const", ".", "TYPE_STATION", "station", ".", "name", "=", "\"Today's Hits Radio\"", "...
[ 88, 0 ]
[ 98, 33 ]
python
en
['en', 'la', 'en']
True
input_sources_fixture
()
Create a set of input sources for testing.
Create a set of input sources for testing.
def input_sources_fixture() -> Sequence[InputSource]: """Create a set of input sources for testing.""" source = Mock(InputSource) source.player_id = 1 source.input_name = const.INPUT_AUX_IN_1 source.name = "HEOS Drive - Line In 1" return [source]
[ "def", "input_sources_fixture", "(", ")", "->", "Sequence", "[", "InputSource", "]", ":", "source", "=", "Mock", "(", "InputSource", ")", "source", ".", "player_id", "=", "1", "source", ".", "input_name", "=", "const", ".", "INPUT_AUX_IN_1", "source", ".", ...
[ 102, 0 ]
[ 108, 19 ]
python
en
['en', 'en', 'en']
True
dispatcher_fixture
()
Create a dispatcher for testing.
Create a dispatcher for testing.
def dispatcher_fixture() -> Dispatcher: """Create a dispatcher for testing.""" return Dispatcher()
[ "def", "dispatcher_fixture", "(", ")", "->", "Dispatcher", ":", "return", "Dispatcher", "(", ")" ]
[ 112, 0 ]
[ 114, 23 ]
python
en
['en', 'en', 'en']
True
discovery_data_fixture
()
Return mock discovery data for testing.
Return mock discovery data for testing.
def discovery_data_fixture() -> dict: """Return mock discovery data for testing.""" return { ssdp.ATTR_SSDP_LOCATION: "http://127.0.0.1:60006/upnp/desc/aios_device/aios_device.xml", ssdp.ATTR_UPNP_DEVICE_TYPE: "urn:schemas-denon-com:device:AiosDevice:1", ssdp.ATTR_UPNP_FRIENDLY_NAME: "Of...
[ "def", "discovery_data_fixture", "(", ")", "->", "dict", ":", "return", "{", "ssdp", ".", "ATTR_SSDP_LOCATION", ":", "\"http://127.0.0.1:60006/upnp/desc/aios_device/aios_device.xml\"", ",", "ssdp", ".", "ATTR_UPNP_DEVICE_TYPE", ":", "\"urn:schemas-denon-com:device:AiosDevice:1\...
[ 118, 0 ]
[ 129, 5 ]
python
en
['en', 'en', 'en']
True
quick_selects_fixture
()
Create a dict of quick selects for testing.
Create a dict of quick selects for testing.
def quick_selects_fixture() -> Dict[int, str]: """Create a dict of quick selects for testing.""" return { 1: "Quick Select 1", 2: "Quick Select 2", 3: "Quick Select 3", 4: "Quick Select 4", 5: "Quick Select 5", 6: "Quick Select 6", }
[ "def", "quick_selects_fixture", "(", ")", "->", "Dict", "[", "int", ",", "str", "]", ":", "return", "{", "1", ":", "\"Quick Select 1\"", ",", "2", ":", "\"Quick Select 2\"", ",", "3", ":", "\"Quick Select 3\"", ",", "4", ":", "\"Quick Select 4\"", ",", "5"...
[ 133, 0 ]
[ 142, 5 ]
python
en
['en', 'en', 'en']
True