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
test_set_wakeup
(hass, mock_openzwave, zwave_setup_ready)
Test zwave set_wakeup service.
Test zwave set_wakeup service.
async def test_set_wakeup(hass, mock_openzwave, zwave_setup_ready): """Test zwave set_wakeup service.""" zwave_network = hass.data[DATA_NETWORK] value = MockValue(index=12, command_class=const.COMMAND_CLASS_WAKE_UP) node = MockNode(node_id=14) node.values = {12: value} node.get_values.return_va...
[ "async", "def", "test_set_wakeup", "(", "hass", ",", "mock_openzwave", ",", "zwave_setup_ready", ")", ":", "zwave_network", "=", "hass", ".", "data", "[", "DATA_NETWORK", "]", "value", "=", "MockValue", "(", "index", "=", "12", ",", "command_class", "=", "co...
[ 1722, 0 ]
[ 1745, 27 ]
python
pl
['pl', 'su', 'sw']
False
test_reset_node_meters
(hass, mock_openzwave, zwave_setup_ready)
Test zwave reset_node_meters service.
Test zwave reset_node_meters service.
async def test_reset_node_meters(hass, mock_openzwave, zwave_setup_ready): """Test zwave reset_node_meters service.""" zwave_network = hass.data[DATA_NETWORK] value = MockValue( instance=1, index=8, data=99.5, command_class=const.COMMAND_CLASS_METER ) reset_value = MockValue( instan...
[ "async", "def", "test_reset_node_meters", "(", "hass", ",", "mock_openzwave", ",", "zwave_setup_ready", ")", ":", "zwave_network", "=", "hass", ".", "data", "[", "DATA_NETWORK", "]", "value", "=", "MockValue", "(", "instance", "=", "1", ",", "index", "=", "8...
[ 1748, 0 ]
[ 1783, 43 ]
python
de
['de', 'nl', 'en']
False
test_add_association
(hass, mock_openzwave, zwave_setup_ready)
Test zwave change_association service.
Test zwave change_association service.
async def test_add_association(hass, mock_openzwave, zwave_setup_ready): """Test zwave change_association service.""" zwave_network = hass.data[DATA_NETWORK] ZWaveGroup = mock_openzwave.group.ZWaveGroup group = MagicMock() ZWaveGroup.return_value = group value = MockValue(index=12, command_cla...
[ "async", "def", "test_add_association", "(", "hass", ",", "mock_openzwave", ",", "zwave_setup_ready", ")", ":", "zwave_network", "=", "hass", ".", "data", "[", "DATA_NETWORK", "]", "ZWaveGroup", "=", "mock_openzwave", ".", "group", ".", "ZWaveGroup", "group", "=...
[ 1786, 0 ]
[ 1820, 57 ]
python
de
['pl', 'de', 'en']
False
test_remove_association
(hass, mock_openzwave, zwave_setup_ready)
Test zwave change_association service.
Test zwave change_association service.
async def test_remove_association(hass, mock_openzwave, zwave_setup_ready): """Test zwave change_association service.""" zwave_network = hass.data[DATA_NETWORK] ZWaveGroup = mock_openzwave.group.ZWaveGroup group = MagicMock() ZWaveGroup.return_value = group value = MockValue(index=12, command_...
[ "async", "def", "test_remove_association", "(", "hass", ",", "mock_openzwave", ",", "zwave_setup_ready", ")", ":", "zwave_network", "=", "hass", ".", "data", "[", "DATA_NETWORK", "]", "ZWaveGroup", "=", "mock_openzwave", ".", "group", ".", "ZWaveGroup", "group", ...
[ 1823, 0 ]
[ 1857, 60 ]
python
de
['pl', 'de', 'en']
False
test_refresh_entity
(hass, mock_openzwave, zwave_setup_ready)
Test zwave refresh_entity service.
Test zwave refresh_entity service.
async def test_refresh_entity(hass, mock_openzwave, zwave_setup_ready): """Test zwave refresh_entity service.""" node = MockNode() value = MockValue( data=False, node=node, command_class=const.COMMAND_CLASS_SENSOR_BINARY ) power_value = MockValue(data=50, node=node, command_class=const.COMMA...
[ "async", "def", "test_refresh_entity", "(", "hass", ",", "mock_openzwave", ",", "zwave_setup_ready", ")", ":", "node", "=", "MockNode", "(", ")", "value", "=", "MockValue", "(", "data", "=", "False", ",", "node", "=", "node", ",", "command_class", "=", "co...
[ 1860, 0 ]
[ 1889, 5 ]
python
de
['pl', 'de', 'en']
False
test_refresh_node
(hass, mock_openzwave, zwave_setup_ready)
Test zwave refresh_node service.
Test zwave refresh_node service.
async def test_refresh_node(hass, mock_openzwave, zwave_setup_ready): """Test zwave refresh_node service.""" zwave_network = hass.data[DATA_NETWORK] node = MockNode(node_id=14) zwave_network.nodes = {14: node} await hass.services.async_call("zwave", "refresh_node", {const.ATTR_NODE_ID: 14}) awa...
[ "async", "def", "test_refresh_node", "(", "hass", ",", "mock_openzwave", ",", "zwave_setup_ready", ")", ":", "zwave_network", "=", "hass", ".", "data", "[", "DATA_NETWORK", "]", "node", "=", "MockNode", "(", "node_id", "=", "14", ")", "zwave_network", ".", "...
[ 1892, 0 ]
[ 1902, 49 ]
python
de
['pl', 'de', 'it']
False
test_set_node_value
(hass, mock_openzwave, zwave_setup_ready)
Test zwave set_node_value service.
Test zwave set_node_value service.
async def test_set_node_value(hass, mock_openzwave, zwave_setup_ready): """Test zwave set_node_value service.""" zwave_network = hass.data[DATA_NETWORK] value = MockValue(index=12, command_class=const.COMMAND_CLASS_INDICATOR, data=4) node = MockNode(node_id=14, command_classes=[const.COMMAND_CLASS_INDI...
[ "async", "def", "test_set_node_value", "(", "hass", ",", "mock_openzwave", ",", "zwave_setup_ready", ")", ":", "zwave_network", "=", "hass", ".", "data", "[", "DATA_NETWORK", "]", "value", "=", "MockValue", "(", "index", "=", "12", ",", "command_class", "=", ...
[ 1905, 0 ]
[ 1926, 55 ]
python
da
['de', 'da', 'en']
False
test_set_node_value_with_long_id_and_text_value
( hass, mock_openzwave, zwave_setup_ready )
Test zwave set_node_value service.
Test zwave set_node_value service.
async def test_set_node_value_with_long_id_and_text_value( hass, mock_openzwave, zwave_setup_ready ): """Test zwave set_node_value service.""" zwave_network = hass.data[DATA_NETWORK] value = MockValue( index=87512398541236578, command_class=const.COMMAND_CLASS_SWITCH_COLOR, data...
[ "async", "def", "test_set_node_value_with_long_id_and_text_value", "(", "hass", ",", "mock_openzwave", ",", "zwave_setup_ready", ")", ":", "zwave_network", "=", "hass", ".", "data", "[", "DATA_NETWORK", "]", "value", "=", "MockValue", "(", "index", "=", "87512398541...
[ 1929, 0 ]
[ 1956, 78 ]
python
da
['de', 'da', 'en']
False
test_refresh_node_value
(hass, mock_openzwave, zwave_setup_ready)
Test zwave refresh_node_value service.
Test zwave refresh_node_value service.
async def test_refresh_node_value(hass, mock_openzwave, zwave_setup_ready): """Test zwave refresh_node_value service.""" zwave_network = hass.data[DATA_NETWORK] node = MockNode( node_id=14, command_classes=[const.COMMAND_CLASS_INDICATOR], network=zwave_network, ) value = Moc...
[ "async", "def", "test_refresh_node_value", "(", "hass", ",", "mock_openzwave", ",", "zwave_setup_ready", ")", ":", "zwave_network", "=", "hass", ".", "data", "[", "DATA_NETWORK", "]", "node", "=", "MockNode", "(", "node_id", "=", "14", ",", "command_classes", ...
[ 1959, 0 ]
[ 1984, 31 ]
python
de
['pl', 'de', 'it']
False
test_heal_node
(hass, mock_openzwave, zwave_setup_ready)
Test zwave heal_node service.
Test zwave heal_node service.
async def test_heal_node(hass, mock_openzwave, zwave_setup_ready): """Test zwave heal_node service.""" zwave_network = hass.data[DATA_NETWORK] node = MockNode(node_id=19) zwave_network.nodes = {19: node} await hass.services.async_call("zwave", "heal_node", {const.ATTR_NODE_ID: 19}) await hass.a...
[ "async", "def", "test_heal_node", "(", "hass", ",", "mock_openzwave", ",", "zwave_setup_ready", ")", ":", "zwave_network", "=", "hass", ".", "data", "[", "DATA_NETWORK", "]", "node", "=", "MockNode", "(", "node_id", "=", "19", ")", "zwave_network", ".", "nod...
[ 1987, 0 ]
[ 1997, 41 ]
python
de
['pl', 'de', 'sw']
False
test_test_node
(hass, mock_openzwave, zwave_setup_ready)
Test the zwave test_node service.
Test the zwave test_node service.
async def test_test_node(hass, mock_openzwave, zwave_setup_ready): """Test the zwave test_node service.""" zwave_network = hass.data[DATA_NETWORK] node = MockNode(node_id=19) zwave_network.nodes = {19: node} await hass.services.async_call("zwave", "test_node", {const.ATTR_NODE_ID: 19}) await ha...
[ "async", "def", "test_test_node", "(", "hass", ",", "mock_openzwave", ",", "zwave_setup_ready", ")", ":", "zwave_network", "=", "hass", ".", "data", "[", "DATA_NETWORK", "]", "node", "=", "MockNode", "(", "node_id", "=", "19", ")", "zwave_network", ".", "nod...
[ 2000, 0 ]
[ 2010, 41 ]
python
en
['en', 'de', 'en']
True
async_increment
(hass, entity_id)
Increment a counter.
Increment a counter.
def async_increment(hass, entity_id): """Increment a counter.""" hass.async_add_job( hass.services.async_call(DOMAIN, SERVICE_INCREMENT, {ATTR_ENTITY_ID: entity_id}) )
[ "def", "async_increment", "(", "hass", ",", "entity_id", ")", ":", "hass", ".", "async_add_job", "(", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_INCREMENT", ",", "{", "ATTR_ENTITY_ID", ":", "entity_id", "}", ")", ")" ]
[ 18, 0 ]
[ 22, 5 ]
python
en
['es', 'en', 'en']
True
async_decrement
(hass, entity_id)
Decrement a counter.
Decrement a counter.
def async_decrement(hass, entity_id): """Decrement a counter.""" hass.async_add_job( hass.services.async_call(DOMAIN, SERVICE_DECREMENT, {ATTR_ENTITY_ID: entity_id}) )
[ "def", "async_decrement", "(", "hass", ",", "entity_id", ")", ":", "hass", ".", "async_add_job", "(", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_DECREMENT", ",", "{", "ATTR_ENTITY_ID", ":", "entity_id", "}", ")", ")" ]
[ 27, 0 ]
[ 31, 5 ]
python
en
['es', 'fr', 'en']
False
async_reset
(hass, entity_id)
Reset a counter.
Reset a counter.
def async_reset(hass, entity_id): """Reset a counter.""" hass.async_add_job( hass.services.async_call(DOMAIN, SERVICE_RESET, {ATTR_ENTITY_ID: entity_id}) )
[ "def", "async_reset", "(", "hass", ",", "entity_id", ")", ":", "hass", ".", "async_add_job", "(", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_RESET", ",", "{", "ATTR_ENTITY_ID", ":", "entity_id", "}", ")", ")" ]
[ 36, 0 ]
[ 40, 5 ]
python
en
['en', 'en', 'en']
True
test_availability_poll_state_once
( hass, mqtt_client_mock, mqtt_mock, setup_tasmota )
Test several entities send a single message to update state.
Test several entities send a single message to update state.
async def test_availability_poll_state_once( hass, mqtt_client_mock, mqtt_mock, setup_tasmota ): """Test several entities send a single message to update state.""" config = copy.deepcopy(DEFAULT_CONFIG) config["rl"][0] = 1 config["rl"][1] = 1 config["swc"][0] = 1 config["swc"][1] = 1 pol...
[ "async", "def", "test_availability_poll_state_once", "(", "hass", ",", "mqtt_client_mock", ",", "mqtt_mock", ",", "setup_tasmota", ")", ":", "config", "=", "copy", ".", "deepcopy", "(", "DEFAULT_CONFIG", ")", "config", "[", "\"rl\"", "]", "[", "0", "]", "=", ...
[ 15, 0 ]
[ 52, 5 ]
python
en
['en', 'en', 'en']
True
load_adj_from_csv
(file: str, skiprows: int = 0)
Read adj information from csv file. Args: file (str): Csv file to read. skiprows (int): Row number to skip. Returns: list: A 2-dim list that contains all the rows and columns.
Read adj information from csv file.
def load_adj_from_csv(file: str, skiprows: int = 0): """Read adj information from csv file. Args: file (str): Csv file to read. skiprows (int): Row number to skip. Returns: list: A 2-dim list that contains all the rows and columns. """ adj = [] if file.startswith("~"): ...
[ "def", "load_adj_from_csv", "(", "file", ":", "str", ",", "skiprows", ":", "int", "=", "0", ")", ":", "adj", "=", "[", "]", "if", "file", ".", "startswith", "(", "\"~\"", ")", ":", "file", "=", "os", ".", "path", ".", "expanduser", "(", "file", "...
[ 7, 0 ]
[ 31, 14 ]
python
en
['en', 'en', 'en']
True
test_config_flow
( hass, legacy_patchable_time, pvpc_aioclient_mock: AiohttpClientMocker )
Test config flow for pvpc_hourly_pricing. - Create a new entry with tariff "normal" - Check state and attributes - Check abort when trying to config another with same tariff - Check removal and add again to check state restoration
Test config flow for pvpc_hourly_pricing.
async def test_config_flow( hass, legacy_patchable_time, pvpc_aioclient_mock: AiohttpClientMocker ): """ Test config flow for pvpc_hourly_pricing. - Create a new entry with tariff "normal" - Check state and attributes - Check abort when trying to config another with same tariff - Check remo...
[ "async", "def", "test_config_flow", "(", "hass", ",", "legacy_patchable_time", ",", "pvpc_aioclient_mock", ":", "AiohttpClientMocker", ")", ":", "hass", ".", "config", ".", "time_zone", "=", "timezone", "(", "\"Europe/Madrid\"", ")", "mock_data", "=", "{", "\"retu...
[ 17, 0 ]
[ 80, 50 ]
python
en
['en', 'error', 'th']
False
mock_load_json
()
Mock load_json.
Mock load_json.
def mock_load_json(): """Mock load_json.""" with patch("homeassistant.components.ios.load_json", return_value={}): yield
[ "def", "mock_load_json", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.ios.load_json\"", ",", "return_value", "=", "{", "}", ")", ":", "yield" ]
[ 12, 0 ]
[ 15, 13 ]
python
en
['en', 'da', 'en']
False
mock_dependencies
(hass)
Mock dependencies loaded.
Mock dependencies loaded.
def mock_dependencies(hass): """Mock dependencies loaded.""" mock_component(hass, "zeroconf") mock_component(hass, "device_tracker")
[ "def", "mock_dependencies", "(", "hass", ")", ":", "mock_component", "(", "hass", ",", "\"zeroconf\"", ")", "mock_component", "(", "hass", ",", "\"device_tracker\"", ")" ]
[ 19, 0 ]
[ 22, 42 ]
python
af
['es', 'af', 'en']
False
test_creating_entry_sets_up_sensor
(hass)
Test setting up iOS loads the sensor component.
Test setting up iOS loads the sensor component.
async def test_creating_entry_sets_up_sensor(hass): """Test setting up iOS loads the sensor component.""" with patch( "homeassistant.components.ios.sensor.async_setup_entry", return_value=mock_coro(True), ) as mock_setup: assert await async_setup_component(hass, ios.DOMAIN, {ios.DOMA...
[ "async", "def", "test_creating_entry_sets_up_sensor", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.ios.sensor.async_setup_entry\"", ",", "return_value", "=", "mock_coro", "(", "True", ")", ",", ")", "as", "mock_setup", ":", "assert", "await...
[ 25, 0 ]
[ 34, 42 ]
python
en
['en', 'en', 'en']
True
test_configuring_ios_creates_entry
(hass)
Test that specifying config will create an entry.
Test that specifying config will create an entry.
async def test_configuring_ios_creates_entry(hass): """Test that specifying config will create an entry.""" with patch( "homeassistant.components.ios.async_setup_entry", return_value=mock_coro(True) ) as mock_setup: await async_setup_component(hass, ios.DOMAIN, {"ios": {"push": {}}}) ...
[ "async", "def", "test_configuring_ios_creates_entry", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.ios.async_setup_entry\"", ",", "return_value", "=", "mock_coro", "(", "True", ")", ")", "as", "mock_setup", ":", "await", "async_setup_componen...
[ 37, 0 ]
[ 45, 42 ]
python
en
['en', 'en', 'en']
True
test_not_configuring_ios_not_creates_entry
(hass)
Test that no config will not create an entry.
Test that no config will not create an entry.
async def test_not_configuring_ios_not_creates_entry(hass): """Test that no config will not create an entry.""" with patch( "homeassistant.components.ios.async_setup_entry", return_value=mock_coro(True) ) as mock_setup: await async_setup_component(hass, ios.DOMAIN, {"foo": "bar"}) aw...
[ "async", "def", "test_not_configuring_ios_not_creates_entry", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.ios.async_setup_entry\"", ",", "return_value", "=", "mock_coro", "(", "True", ")", ")", "as", "mock_setup", ":", "await", "async_setup_...
[ 48, 0 ]
[ 56, 42 ]
python
en
['en', 'en', 'en']
True
async_get
(hass: HomeAssistant)
Get unique ID for the hass instance.
Get unique ID for the hass instance.
async def async_get(hass: HomeAssistant) -> str: """Get unique ID for the hass instance.""" store = storage.Store(hass, DATA_VERSION, DATA_KEY, True) data: Optional[Dict[str, str]] = await storage.async_migrator( # type: ignore hass, hass.config.path(LEGACY_UUID_FILE), store, )...
[ "async", "def", "async_get", "(", "hass", ":", "HomeAssistant", ")", "->", "str", ":", "store", "=", "storage", ".", "Store", "(", "hass", ",", "DATA_VERSION", ",", "DATA_KEY", ",", "True", ")", "data", ":", "Optional", "[", "Dict", "[", "str", ",", ...
[ 15, 0 ]
[ 32, 23 ]
python
en
['en', 'en', 'en']
True
test_events_fired_properly
(hass)
Test that events are fired correctly.
Test that events are fired correctly.
async def test_events_fired_properly(hass): """Test that events are fired correctly.""" binding = EmulatedRoku( hass, "Test Emulated Roku", "1.2.3.4", 8060, None, None, None ) events = [] roku_event_handler = None def instantiate( loop, handler, roku_usn, ...
[ "async", "def", "test_events_fired_properly", "(", "hass", ")", ":", "binding", "=", "EmulatedRoku", "(", "hass", ",", "\"Test Emulated Roku\"", ",", "\"1.2.3.4\"", ",", "8060", ",", "None", ",", "None", ",", "None", ")", "events", "=", "[", "]", "roku_event...
[ 17, 0 ]
[ 80, 45 ]
python
en
['en', 'en', 'en']
True
SpeedTestFlowHandler.async_get_options_flow
(config_entry)
Get the options flow for this handler.
Get the options flow for this handler.
def async_get_options_flow(config_entry): """Get the options flow for this handler.""" return SpeedTestOptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "SpeedTestOptionsFlowHandler", "(", "config_entry", ")" ]
[ 27, 4 ]
[ 29, 56 ]
python
en
['en', 'en', 'en']
True
SpeedTestFlowHandler.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 self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") if user_input is None: return self.async_show_form(step_id="user") return s...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "self", ".", "_async_current_entries", "(", ")", ":", "return", "self", ".", "async_abort", "(", "reason", "=", "\"single_instance_allowed\"", ")", "if", "user_inpu...
[ 31, 4 ]
[ 39, 75 ]
python
en
['en', 'en', 'en']
True
SpeedTestFlowHandler.async_step_import
(self, import_config)
Import from config.
Import from config.
async def async_step_import(self, import_config): """Import from config.""" if ( CONF_SERVER_ID in import_config and not await self.hass.async_add_executor_job( server_id_valid, import_config[CONF_SERVER_ID] ) ): return self.async_a...
[ "async", "def", "async_step_import", "(", "self", ",", "import_config", ")", ":", "if", "(", "CONF_SERVER_ID", "in", "import_config", "and", "not", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "server_id_valid", ",", "import_config", "[", "C...
[ 41, 4 ]
[ 56, 67 ]
python
en
['en', 'en', 'en']
True
SpeedTestOptionsFlowHandler.__init__
(self, config_entry)
Initialize options flow.
Initialize options flow.
def __init__(self, config_entry): """Initialize options flow.""" self.config_entry = config_entry self._servers = {}
[ "def", "__init__", "(", "self", ",", "config_entry", ")", ":", "self", ".", "config_entry", "=", "config_entry", "self", ".", "_servers", "=", "{", "}" ]
[ 62, 4 ]
[ 65, 26 ]
python
en
['en', 'en', 'en']
True
SpeedTestOptionsFlowHandler.async_step_init
(self, user_input=None)
Manage the options.
Manage the options.
async def async_step_init(self, user_input=None): """Manage the options.""" errors = {} if user_input is not None: server_name = user_input[CONF_SERVER_NAME] if server_name != "*Auto Detect": server_id = self._servers[server_name]["id"] us...
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "server_name", "=", "user_input", "[", "CONF_SERVER_NAME", "]", "if", "server_name", "!=", "\"*...
[ 67, 4 ]
[ 112, 9 ]
python
en
['en', 'en', 'en']
True
get_service
(hass, config, discovery_info=None)
Get the Mailgun notification service.
Get the Mailgun notification service.
def get_service(hass, config, discovery_info=None): """Get the Mailgun notification service.""" data = hass.data[MAILGUN_DOMAIN] mailgun_service = MailgunNotificationService( data.get(CONF_DOMAIN), data.get(CONF_SANDBOX), data.get(CONF_API_KEY), config.get(CONF_SENDER), ...
[ "def", "get_service", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "data", "=", "hass", ".", "data", "[", "MAILGUN_DOMAIN", "]", "mailgun_service", "=", "MailgunNotificationService", "(", "data", ".", "get", "(", "CONF_DOMAIN", "...
[ 35, 0 ]
[ 48, 15 ]
python
en
['en', 'de', 'en']
True
MailgunNotificationService.__init__
(self, domain, sandbox, api_key, sender, recipient)
Initialize the service.
Initialize the service.
def __init__(self, domain, sandbox, api_key, sender, recipient): """Initialize the service.""" self._client = None # Mailgun API client self._domain = domain self._sandbox = sandbox self._api_key = api_key self._sender = sender self._recipient = recipient
[ "def", "__init__", "(", "self", ",", "domain", ",", "sandbox", ",", "api_key", ",", "sender", ",", "recipient", ")", ":", "self", ".", "_client", "=", "None", "# Mailgun API client", "self", ".", "_domain", "=", "domain", "self", ".", "_sandbox", "=", "s...
[ 54, 4 ]
[ 61, 35 ]
python
en
['en', 'en', 'en']
True
MailgunNotificationService.initialize_client
(self)
Initialize the connection to Mailgun.
Initialize the connection to Mailgun.
def initialize_client(self): """Initialize the connection to Mailgun.""" self._client = Client(self._api_key, self._domain, self._sandbox) _LOGGER.debug("Mailgun domain: %s", self._client.domain) self._domain = self._client.domain if not self._sender: self._sender = ...
[ "def", "initialize_client", "(", "self", ")", ":", "self", ".", "_client", "=", "Client", "(", "self", ".", "_api_key", ",", "self", ".", "_domain", ",", "self", ".", "_sandbox", ")", "_LOGGER", ".", "debug", "(", "\"Mailgun domain: %s\"", ",", "self", "...
[ 63, 4 ]
[ 70, 49 ]
python
en
['en', 'en', 'en']
True
MailgunNotificationService.connection_is_valid
(self)
Check whether the provided credentials are valid.
Check whether the provided credentials are valid.
def connection_is_valid(self): """Check whether the provided credentials are valid.""" try: self.initialize_client() except MailgunCredentialsError: _LOGGER.exception("Invalid credentials") return False except MailgunDomainError as mailgun_error: ...
[ "def", "connection_is_valid", "(", "self", ")", ":", "try", ":", "self", ".", "initialize_client", "(", ")", "except", "MailgunCredentialsError", ":", "_LOGGER", ".", "exception", "(", "\"Invalid credentials\"", ")", "return", "False", "except", "MailgunDomainError"...
[ 72, 4 ]
[ 83, 19 ]
python
en
['en', 'en', 'en']
True
MailgunNotificationService.send_message
(self, message="", **kwargs)
Send a mail to the recipient.
Send a mail to the recipient.
def send_message(self, message="", **kwargs): """Send a mail to the recipient.""" subject = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT) data = kwargs.get(ATTR_DATA) files = data.get(ATTR_IMAGES) if data else None try: # Initialize the client in case it was not. ...
[ "def", "send_message", "(", "self", ",", "message", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "subject", "=", "kwargs", ".", "get", "(", "ATTR_TITLE", ",", "ATTR_TITLE_DEFAULT", ")", "data", "=", "kwargs", ".", "get", "(", "ATTR_DATA", ")", "file...
[ 85, 4 ]
[ 105, 74 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up AWS component.
Set up AWS component.
async def async_setup(hass, config): """Set up AWS component.""" hass.data[DATA_HASS_CONFIG] = config conf = config.get(DOMAIN) if conf is None: # create a default conf using default profile conf = CONFIG_SCHEMA({ATTR_CREDENTIALS: DEFAULT_CREDENTIAL}) hass.data[DATA_CONFIG] = conf ...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "hass", ".", "data", "[", "DATA_HASS_CONFIG", "]", "=", "config", "conf", "=", "config", ".", "get", "(", "DOMAIN", ")", "if", "conf", "is", "None", ":", "# create a default conf using de...
[ 80, 0 ]
[ 98, 15 ]
python
en
['en', 'pt', 'en']
True
async_setup_entry
(hass, entry)
Load a config entry. Validate and save sessions per aws credential.
Load a config entry.
async def async_setup_entry(hass, entry): """Load a config entry. Validate and save sessions per aws credential. """ config = hass.data.get(DATA_HASS_CONFIG) conf = hass.data.get(DATA_CONFIG) if entry.source == config_entries.SOURCE_IMPORT: if conf is None: # user removed c...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ")", ":", "config", "=", "hass", ".", "data", ".", "get", "(", "DATA_HASS_CONFIG", ")", "conf", "=", "hass", ".", "data", ".", "get", "(", "DATA_CONFIG", ")", "if", "entry", ".", "source",...
[ 101, 0 ]
[ 149, 21 ]
python
en
['en', 'en', 'en']
True
_validate_aws_credentials
(hass, credential)
Validate AWS credential config.
Validate AWS credential config.
async def _validate_aws_credentials(hass, credential): """Validate AWS credential config.""" aws_config = credential.copy() del aws_config[CONF_NAME] del aws_config[CONF_VALIDATE] profile = aws_config.get(CONF_PROFILE_NAME) if profile is not None: session = aiobotocore.AioSession(prof...
[ "async", "def", "_validate_aws_credentials", "(", "hass", ",", "credential", ")", ":", "aws_config", "=", "credential", ".", "copy", "(", ")", "del", "aws_config", "[", "CONF_NAME", "]", "del", "aws_config", "[", "CONF_VALIDATE", "]", "profile", "=", "aws_conf...
[ 152, 0 ]
[ 175, 18 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Command line Binary Sensor.
Set up the Command line Binary Sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Command line Binary Sensor.""" setup_reload_service(hass, DOMAIN, PLATFORMS) name = config.get(CONF_NAME) command = config.get(CONF_COMMAND) payload_off = config.get(CONF_PAYLOAD_OFF) payload_on = config.get(CON...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "setup_reload_service", "(", "hass", ",", "DOMAIN", ",", "PLATFORMS", ")", "name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "co...
[ 44, 0 ]
[ 67, 5 ]
python
en
['en', 'haw', 'en']
True
CommandBinarySensor.__init__
( self, hass, data, name, device_class, payload_on, payload_off, value_template )
Initialize the Command line binary sensor.
Initialize the Command line binary sensor.
def __init__( self, hass, data, name, device_class, payload_on, payload_off, value_template ): """Initialize the Command line binary sensor.""" self._hass = hass self.data = data self._name = name self._device_class = device_class self._state = False s...
[ "def", "__init__", "(", "self", ",", "hass", ",", "data", ",", "name", ",", "device_class", ",", "payload_on", ",", "payload_off", ",", "value_template", ")", ":", "self", ".", "_hass", "=", "hass", "self", ".", "data", "=", "data", "self", ".", "_name...
[ 73, 4 ]
[ 84, 45 ]
python
en
['en', 'haw', 'en']
True
CommandBinarySensor.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" ]
[ 87, 4 ]
[ 89, 25 ]
python
en
['en', 'mi', 'en']
True
CommandBinarySensor.is_on
(self)
Return true if the binary sensor is on.
Return true if the binary sensor is on.
def is_on(self): """Return true if the binary sensor is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 92, 4 ]
[ 94, 26 ]
python
en
['en', 'fy', 'en']
True
CommandBinarySensor.device_class
(self)
Return the class of the binary sensor.
Return the class of the binary sensor.
def device_class(self): """Return the class of the binary sensor.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 97, 4 ]
[ 99, 33 ]
python
en
['en', 'tg', 'en']
True
CommandBinarySensor.update
(self)
Get the latest data and updates the state.
Get the latest data and updates the state.
def update(self): """Get the latest data and updates the state.""" self.data.update() value = self.data.value if self._value_template is not None: value = self._value_template.render_with_possible_json_value(value, False) if value == self._payload_on: sel...
[ "def", "update", "(", "self", ")", ":", "self", ".", "data", ".", "update", "(", ")", "value", "=", "self", ".", "data", ".", "value", "if", "self", ".", "_value_template", "is", "not", "None", ":", "value", "=", "self", ".", "_value_template", ".", ...
[ 101, 4 ]
[ 111, 31 ]
python
en
['en', 'en', 'en']
True
_data_schema
(schema_input)
Generate schema with defaults.
Generate schema with defaults.
def _data_schema(schema_input): """Generate schema with defaults.""" return vol.Schema( { vol.Required(CONF_HOST, default=schema_input.get(CONF_HOST, "")): str, vol.Required(CONF_USERNAME): str, vol.Required(CONF_PASSWORD): str, vol.Optional(CONF_TLS_VER, ...
[ "def", "_data_schema", "(", "schema_input", ")", ":", "return", "vol", ".", "Schema", "(", "{", "vol", ".", "Required", "(", "CONF_HOST", ",", "default", "=", "schema_input", ".", "get", "(", "CONF_HOST", ",", "\"\"", ")", ")", ":", "str", ",", "vol", ...
[ 32, 0 ]
[ 42, 5 ]
python
en
['en', 'en', 'en']
True
validate_input
(hass: core.HomeAssistant, data)
Validate the user input allows us to connect. Data has the keys from DATA_SCHEMA with values provided by the user.
Validate the user input allows us to connect.
async def validate_input(hass: core.HomeAssistant, data): """Validate the user input allows us to connect. Data has the keys from DATA_SCHEMA with values provided by the user. """ user = data[CONF_USERNAME] password = data[CONF_PASSWORD] host = urlparse(data[CONF_HOST]) tls_version = data.g...
[ "async", "def", "validate_input", "(", "hass", ":", "core", ".", "HomeAssistant", ",", "data", ")", ":", "user", "=", "data", "[", "CONF_USERNAME", "]", "password", "=", "data", "[", "CONF_PASSWORD", "]", "host", "=", "urlparse", "(", "data", "[", "CONF_...
[ 45, 0 ]
[ 81, 87 ]
python
en
['en', 'en', 'en']
True
_fetch_isy_configuration
( address, port, username, password, use_https, tls_ver, webroot )
Validate and fetch the configuration from the ISY.
Validate and fetch the configuration from the ISY.
def _fetch_isy_configuration( address, port, username, password, use_https, tls_ver, webroot ): """Validate and fetch the configuration from the ISY.""" try: isy_conn = Connection( address, port, username, password, use_https, t...
[ "def", "_fetch_isy_configuration", "(", "address", ",", "port", ",", "username", ",", "password", ",", "use_https", ",", "tls_ver", ",", "webroot", ")", ":", "try", ":", "isy_conn", "=", "Connection", "(", "address", ",", "port", ",", "username", ",", "pas...
[ 84, 0 ]
[ 101, 51 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.__init__
(self)
Initialize the isy994 config flow.
Initialize the isy994 config flow.
def __init__(self): """Initialize the isy994 config flow.""" self.discovered_conf = {}
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "discovered_conf", "=", "{", "}" ]
[ 110, 4 ]
[ 112, 33 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.async_get_options_flow
(config_entry)
Get the options flow for this handler.
Get the options flow for this handler.
def async_get_options_flow(config_entry): """Get the options flow for this handler.""" return OptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "OptionsFlowHandler", "(", "config_entry", ")" ]
[ 116, 4 ]
[ 118, 47 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.async_step_user
(self, user_input=None)
Handle the initial step.
Handle the initial step.
async def async_step_user(self, user_input=None): """Handle the initial step.""" errors = {} info = None if user_input is not None: try: info = await validate_input(self.hass, user_input) except CannotConnect: errors["base"] = "cann...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "info", "=", "None", "if", "user_input", "is", "not", "None", ":", "try", ":", "info", "=", "await", "validate_input", "(", "self", ".", ...
[ 120, 4 ]
[ 146, 9 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.async_step_import
(self, user_input)
Handle import.
Handle import.
async def async_step_import(self, user_input): """Handle import.""" return await self.async_step_user(user_input)
[ "async", "def", "async_step_import", "(", "self", ",", "user_input", ")", ":", "return", "await", "self", ".", "async_step_user", "(", "user_input", ")" ]
[ 148, 4 ]
[ 150, 53 ]
python
en
['en', 'ja', 'en']
False
ConfigFlow.async_step_ssdp
(self, discovery_info)
Handle a discovered isy994.
Handle a discovered isy994.
async def async_step_ssdp(self, discovery_info): """Handle a discovered isy994.""" friendly_name = discovery_info[ssdp.ATTR_UPNP_FRIENDLY_NAME] url = discovery_info[ssdp.ATTR_SSDP_LOCATION] mac = discovery_info[ssdp.ATTR_UPNP_UDN] if mac.startswith(UDN_UUID_PREFIX): m...
[ "async", "def", "async_step_ssdp", "(", "self", ",", "discovery_info", ")", ":", "friendly_name", "=", "discovery_info", "[", "ssdp", ".", "ATTR_UPNP_FRIENDLY_NAME", "]", "url", "=", "discovery_info", "[", "ssdp", ".", "ATTR_SSDP_LOCATION", "]", "mac", "=", "dis...
[ 152, 4 ]
[ 172, 43 ]
python
en
['en', 'en', 'en']
True
OptionsFlowHandler.__init__
(self, config_entry: config_entries.ConfigEntry)
Initialize options flow.
Initialize options flow.
def __init__(self, config_entry: config_entries.ConfigEntry): """Initialize options flow.""" self.config_entry = config_entry
[ "def", "__init__", "(", "self", ",", "config_entry", ":", "config_entries", ".", "ConfigEntry", ")", ":", "self", ".", "config_entry", "=", "config_entry" ]
[ 178, 4 ]
[ 180, 40 ]
python
en
['en', 'en', 'en']
True
OptionsFlowHandler.async_step_init
(self, user_input=None)
Handle options flow.
Handle options flow.
async def async_step_init(self, user_input=None): """Handle options flow.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) options = self.config_entry.options restore_light_state = options.get( CONF_RESTORE_LIGHT_STATE, DEFA...
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "return", "self", ".", "async_create_entry", "(", "title", "=", "\"\"", ",", "data", "=", "user_input", ")", "options", ...
[ 182, 4 ]
[ 208, 79 ]
python
en
['en', 'nl', 'en']
True
set_global_seeds
(i)
set global seeds
set global seeds
def set_global_seeds(i): """set global seeds""" rank = 0 myseed = i + 1000 * rank if i is not None else None tf.set_random_seed(myseed) np.random.seed(myseed) random.seed(myseed)
[ "def", "set_global_seeds", "(", "i", ")", ":", "rank", "=", "0", "myseed", "=", "i", "+", "1000", "*", "rank", "if", "i", "is", "not", "None", "else", "None", "tf", ".", "set_random_seed", "(", "myseed", ")", "np", ".", "random", ".", "seed", "(", ...
[ 15, 0 ]
[ 21, 23 ]
python
ceb
['mt', 'ceb', 'en']
False
batch_to_seq
(h, nbatch, nsteps, flat=False)
convert from batch to sequence
convert from batch to sequence
def batch_to_seq(h, nbatch, nsteps, flat=False): """convert from batch to sequence""" if flat: h = tf.reshape(h, [nbatch, nsteps]) else: h = tf.reshape(h, [nbatch, nsteps, -1]) return [tf.squeeze(v, [1]) for v in tf.split(axis=1, num_or_size_splits=nsteps, value=h)]
[ "def", "batch_to_seq", "(", "h", ",", "nbatch", ",", "nsteps", ",", "flat", "=", "False", ")", ":", "if", "flat", ":", "h", "=", "tf", ".", "reshape", "(", "h", ",", "[", "nbatch", ",", "nsteps", "]", ")", "else", ":", "h", "=", "tf", ".", "r...
[ 23, 0 ]
[ 29, 93 ]
python
en
['en', 'en', 'en']
True
seq_to_batch
(h, flat=False)
convert from sequence to batch
convert from sequence to batch
def seq_to_batch(h, flat=False): """convert from sequence to batch""" shape = h[0].get_shape().as_list() if not flat: assert len(shape) > 1 nh = h[0].get_shape()[-1].value return tf.reshape(tf.concat(axis=1, values=h), [-1, nh]) else: return tf.reshape(tf.stack(values=h, ...
[ "def", "seq_to_batch", "(", "h", ",", "flat", "=", "False", ")", ":", "shape", "=", "h", "[", "0", "]", ".", "get_shape", "(", ")", ".", "as_list", "(", ")", "if", "not", "flat", ":", "assert", "len", "(", "shape", ")", ">", "1", "nh", "=", "...
[ 31, 0 ]
[ 39, 59 ]
python
en
['en', 'en', 'en']
True
lstm_model
(nlstm=128, layer_norm=False)
Builds LSTM (Long-Short Term Memory) network to be used in a policy. Note that the resulting function returns not only the output of the LSTM (i.e. hidden state of lstm for each step in the sequence), but also a dictionary with auxiliary tensors to be set as policy attributes. Specifically, ...
Builds LSTM (Long-Short Term Memory) network to be used in a policy. Note that the resulting function returns not only the output of the LSTM (i.e. hidden state of lstm for each step in the sequence), but also a dictionary with auxiliary tensors to be set as policy attributes.
def lstm_model(nlstm=128, layer_norm=False): """ Builds LSTM (Long-Short Term Memory) network to be used in a policy. Note that the resulting function returns not only the output of the LSTM (i.e. hidden state of lstm for each step in the sequence), but also a dictionary with auxiliary tensors to be...
[ "def", "lstm_model", "(", "nlstm", "=", "128", ",", "layer_norm", "=", "False", ")", ":", "def", "network_fn", "(", "X", ",", "nenv", "=", "1", ",", "obs_size", "=", "-", "1", ")", ":", "with", "tf", ".", "variable_scope", "(", "\"emb\"", ",", "reu...
[ 65, 0 ]
[ 117, 21 ]
python
en
['en', 'error', 'th']
False
ortho_init
(scale=1.0)
init approach
init approach
def ortho_init(scale=1.0): """init approach""" def _ortho_init(shape, dtype, partition_info=None): #lasagne ortho init for tf shape = tuple(shape) if len(shape) == 2: flat_shape = shape elif len(shape) == 4: # assumes NHWC flat_shape = (np.prod(shape[:-1])...
[ "def", "ortho_init", "(", "scale", "=", "1.0", ")", ":", "def", "_ortho_init", "(", "shape", ",", "dtype", ",", "partition_info", "=", "None", ")", ":", "#lasagne ortho init for tf", "shape", "=", "tuple", "(", "shape", ")", "if", "len", "(", "shape", ")...
[ 119, 0 ]
[ 135, 22 ]
python
en
['en', 'en', 'en']
False
fc
(x, scope, nh, *, init_scale=1.0, init_bias=0.0)
fully connected op
fully connected op
def fc(x, scope, nh, *, init_scale=1.0, init_bias=0.0): """fully connected op""" with tf.variable_scope(scope): nin = x.get_shape()[1].value w = tf.get_variable("w", [nin, nh], initializer=ortho_init(init_scale)) b = tf.get_variable("b", [nh], initializer=tf.constant_initializer(init_bia...
[ "def", "fc", "(", "x", ",", "scope", ",", "nh", ",", "*", ",", "init_scale", "=", "1.0", ",", "init_bias", "=", "0.0", ")", ":", "with", "tf", ".", "variable_scope", "(", "scope", ")", ":", "nin", "=", "x", ".", "get_shape", "(", ")", "[", "1",...
[ 137, 0 ]
[ 143, 32 ]
python
en
['en', 'en', 'en']
True
_check_shape
(placeholder_shape, data_shape)
check if two shapes are compatible (i.e. differ only by dimensions of size 1, or by the batch dimension)
check if two shapes are compatible (i.e. differ only by dimensions of size 1, or by the batch dimension)
def _check_shape(placeholder_shape, data_shape): """ check if two shapes are compatible (i.e. differ only by dimensions of size 1, or by the batch dimension) """ return True
[ "def", "_check_shape", "(", "placeholder_shape", ",", "data_shape", ")", ":", "return", "True" ]
[ 145, 0 ]
[ 150, 15 ]
python
en
['en', 'error', 'th']
False
adjust_shape
(placeholder, data)
adjust shape of the data to the shape of the placeholder if possible. If shape is incompatible, AssertionError is thrown Parameters ---------- placeholder tensorflow input placeholder data input data to be (potentially) reshaped to be fed into placeholder Returns -----...
adjust shape of the data to the shape of the placeholder if possible. If shape is incompatible, AssertionError is thrown
def adjust_shape(placeholder, data): """ adjust shape of the data to the shape of the placeholder if possible. If shape is incompatible, AssertionError is thrown Parameters ---------- placeholder tensorflow input placeholder data input data to be (potentially) reshaped to be...
[ "def", "adjust_shape", "(", "placeholder", ",", "data", ")", ":", "if", "not", "isinstance", "(", "data", ",", "np", ".", "ndarray", ")", "and", "not", "isinstance", "(", "data", ",", "list", ")", ":", "return", "data", "if", "isinstance", "(", "data",...
[ 155, 0 ]
[ 181, 46 ]
python
en
['en', 'error', 'th']
False
get_session
(config=None)
Get default session or create one with a given config
Get default session or create one with a given config
def get_session(config=None): """Get default session or create one with a given config""" sess = tf.get_default_session() if sess is None: sess = make_session(config=config, make_default=True) return sess
[ "def", "get_session", "(", "config", "=", "None", ")", ":", "sess", "=", "tf", ".", "get_default_session", "(", ")", "if", "sess", "is", "None", ":", "sess", "=", "make_session", "(", "config", "=", "config", ",", "make_default", "=", "True", ")", "ret...
[ 187, 0 ]
[ 192, 15 ]
python
en
['en', 'en', 'en']
True
make_session
(config=None, num_cpu=None, make_default=False, graph=None)
Returns a session that will use <num_cpu> CPU's only
Returns a session that will use <num_cpu> CPU's only
def make_session(config=None, num_cpu=None, make_default=False, graph=None): """Returns a session that will use <num_cpu> CPU's only""" if num_cpu is None: num_cpu = int(os.getenv('RCALL_NUM_CPU', multiprocessing.cpu_count())) if config is None: config = tf.ConfigProto( allow_sof...
[ "def", "make_session", "(", "config", "=", "None", ",", "num_cpu", "=", "None", ",", "make_default", "=", "False", ",", "graph", "=", "None", ")", ":", "if", "num_cpu", "is", "None", ":", "num_cpu", "=", "int", "(", "os", ".", "getenv", "(", "'RCALL_...
[ 194, 0 ]
[ 208, 53 ]
python
en
['en', 'en', 'en']
True
initialize
()
Initialize all the uninitialized variables in the global scope.
Initialize all the uninitialized variables in the global scope.
def initialize(): """Initialize all the uninitialized variables in the global scope.""" new_variables = set(tf.global_variables()) - ALREADY_INITIALIZED get_session().run(tf.variables_initializer(new_variables)) ALREADY_INITIALIZED.update(new_variables)
[ "def", "initialize", "(", ")", ":", "new_variables", "=", "set", "(", "tf", ".", "global_variables", "(", ")", ")", "-", "ALREADY_INITIALIZED", "get_session", "(", ")", ".", "run", "(", "tf", ".", "variables_initializer", "(", "new_variables", ")", ")", "A...
[ 212, 0 ]
[ 217, 45 ]
python
en
['en', 'en', 'en']
True
observation_placeholder
(ob_space, batch_size=None, name='Ob')
Create placeholder to feed observations into of the size appropriate to the observation space Parameters ---------- ob_space : gym.Space observation space batch_size : int size of the batch to be fed into input. Can be left None in most cases. name : str name of the pla...
Create placeholder to feed observations into of the size appropriate to the observation space
def observation_placeholder(ob_space, batch_size=None, name='Ob'): """ Create placeholder to feed observations into of the size appropriate to the observation space Parameters ---------- ob_space : gym.Space observation space batch_size : int size of the batch to be fed into inp...
[ "def", "observation_placeholder", "(", "ob_space", ",", "batch_size", "=", "None", ",", "name", "=", "'Ob'", ")", ":", "assert", "isinstance", "(", "ob_space", ",", "(", "Discrete", ",", "Box", ",", "MultiDiscrete", ")", ")", ",", "'Can only deal with Discrete...
[ 219, 0 ]
[ 244, 87 ]
python
en
['en', 'error', 'th']
False
explained_variance
(ypred, y)
Computes fraction of variance that ypred explains about y. Returns 1 - Var[y-ypred] / Var[y] interpretation: ev=0 => might as well have predicted zero ev=1 => perfect prediction ev<0 => worse than just predicting zero
Computes fraction of variance that ypred explains about y. Returns 1 - Var[y-ypred] / Var[y]
def explained_variance(ypred, y): """ Computes fraction of variance that ypred explains about y. Returns 1 - Var[y-ypred] / Var[y] interpretation: ev=0 => might as well have predicted zero ev=1 => perfect prediction ev<0 => worse than just predicting zero """ asse...
[ "def", "explained_variance", "(", "ypred", ",", "y", ")", ":", "assert", "y", ".", "ndim", "==", "1", "and", "ypred", ".", "ndim", "==", "1", "vary", "=", "np", ".", "var", "(", "y", ")", "return", "np", ".", "nan", "if", "vary", "==", "0", "el...
[ 246, 0 ]
[ 259, 60 ]
python
en
['en', 'error', 'th']
False
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Somfy cover platform.
Set up the Somfy cover platform.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Somfy cover platform.""" def get_covers(): """Retrieve covers.""" domain_data = hass.data[DOMAIN] coordinator = domain_data[COORDINATOR] api = domain_data[API] return [ SomfyC...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "def", "get_covers", "(", ")", ":", "\"\"\"Retrieve covers.\"\"\"", "domain_data", "=", "hass", ".", "data", "[", "DOMAIN", "]", "coordinator", "=", "doma...
[ 27, 0 ]
[ 42, 69 ]
python
en
['en', 'da', 'en']
True
SomfyCover.__init__
(self, coordinator, device_id, api, optimistic)
Initialize the Somfy device.
Initialize the Somfy device.
def __init__(self, coordinator, device_id, api, optimistic): """Initialize the Somfy device.""" super().__init__(coordinator, device_id, api) self.categories = set(self.device.categories) self.optimistic = optimistic self._closed = None self._is_opening = None sel...
[ "def", "__init__", "(", "self", ",", "coordinator", ",", "device_id", ",", "api", ",", "optimistic", ")", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ",", "device_id", ",", "api", ")", "self", ".", "categories", "=", "set", "(", "self"...
[ 48, 4 ]
[ 57, 29 ]
python
en
['en', 'en', 'en']
True
SomfyCover._create_device
(self)
Update the device with the latest data.
Update the device with the latest data.
def _create_device(self): """Update the device with the latest data.""" self.cover = Blind(self.device, self.api)
[ "def", "_create_device", "(", "self", ")", ":", "self", ".", "cover", "=", "Blind", "(", "self", ".", "device", ",", "self", ".", "api", ")" ]
[ 59, 4 ]
[ 61, 49 ]
python
en
['en', 'en', 'en']
True
SomfyCover.async_close_cover
(self, **kwargs)
Close the cover.
Close the cover.
async def async_close_cover(self, **kwargs): """Close the cover.""" self._is_closing = True self.async_write_ha_state() try: # Blocks until the close command is sent await self.hass.async_add_executor_job(self.cover.close) self._closed = True f...
[ "async", "def", "async_close_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_is_closing", "=", "True", "self", ".", "async_write_ha_state", "(", ")", "try", ":", "# Blocks until the close command is sent", "await", "self", ".", "hass", "...
[ 63, 4 ]
[ 73, 39 ]
python
en
['en', 'en', 'en']
True
SomfyCover.async_open_cover
(self, **kwargs)
Open the cover.
Open the cover.
async def async_open_cover(self, **kwargs): """Open the cover.""" self._is_opening = True self.async_write_ha_state() try: # Blocks until the open command is sent await self.hass.async_add_executor_job(self.cover.open) self._closed = False fina...
[ "async", "def", "async_open_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_is_opening", "=", "True", "self", ".", "async_write_ha_state", "(", ")", "try", ":", "# Blocks until the open command is sent", "await", "self", ".", "hass", "."...
[ 75, 4 ]
[ 85, 39 ]
python
en
['en', 'en', 'en']
True
SomfyCover.stop_cover
(self, **kwargs)
Stop the cover.
Stop the cover.
def stop_cover(self, **kwargs): """Stop the cover.""" self.cover.stop()
[ "def", "stop_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "cover", ".", "stop", "(", ")" ]
[ 87, 4 ]
[ 89, 25 ]
python
en
['en', 'en', 'en']
True
SomfyCover.set_cover_position
(self, **kwargs)
Move the cover shutter to a specific position.
Move the cover shutter to a specific position.
def set_cover_position(self, **kwargs): """Move the cover shutter to a specific position.""" self.cover.set_position(100 - kwargs[ATTR_POSITION])
[ "def", "set_cover_position", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "cover", ".", "set_position", "(", "100", "-", "kwargs", "[", "ATTR_POSITION", "]", ")" ]
[ 91, 4 ]
[ 93, 60 ]
python
en
['en', 'en', 'en']
True
SomfyCover.device_class
(self)
Return the device class.
Return the device class.
def device_class(self): """Return the device class.""" if self.categories & BLIND_DEVICE_CATEGORIES: return DEVICE_CLASS_BLIND if self.categories & SHUTTER_DEVICE_CATEGORIES: return DEVICE_CLASS_SHUTTER return None
[ "def", "device_class", "(", "self", ")", ":", "if", "self", ".", "categories", "&", "BLIND_DEVICE_CATEGORIES", ":", "return", "DEVICE_CLASS_BLIND", "if", "self", ".", "categories", "&", "SHUTTER_DEVICE_CATEGORIES", ":", "return", "DEVICE_CLASS_SHUTTER", "return", "N...
[ 96, 4 ]
[ 102, 19 ]
python
en
['en', 'en', 'en']
True
SomfyCover.current_cover_position
(self)
Return the current position of cover shutter.
Return the current position of cover shutter.
def current_cover_position(self): """Return the current position of cover shutter.""" position = None if self.has_capability("position"): position = 100 - self.cover.get_position() return position
[ "def", "current_cover_position", "(", "self", ")", ":", "position", "=", "None", "if", "self", ".", "has_capability", "(", "\"position\"", ")", ":", "position", "=", "100", "-", "self", ".", "cover", ".", "get_position", "(", ")", "return", "position" ]
[ 105, 4 ]
[ 110, 23 ]
python
en
['en', 'en', 'en']
True
SomfyCover.is_opening
(self)
Return if the cover is opening.
Return if the cover is opening.
def is_opening(self): """Return if the cover is opening.""" if not self.optimistic: return None return self._is_opening
[ "def", "is_opening", "(", "self", ")", ":", "if", "not", "self", ".", "optimistic", ":", "return", "None", "return", "self", ".", "_is_opening" ]
[ 113, 4 ]
[ 117, 31 ]
python
en
['en', 'en', 'en']
True
SomfyCover.is_closing
(self)
Return if the cover is closing.
Return if the cover is closing.
def is_closing(self): """Return if the cover is closing.""" if not self.optimistic: return None return self._is_closing
[ "def", "is_closing", "(", "self", ")", ":", "if", "not", "self", ".", "optimistic", ":", "return", "None", "return", "self", ".", "_is_closing" ]
[ 120, 4 ]
[ 124, 31 ]
python
en
['en', 'en', 'en']
True
SomfyCover.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.""" is_closed = None if self.has_capability("position"): is_closed = self.cover.is_closed() elif self.optimistic: is_closed = self._closed return is_closed
[ "def", "is_closed", "(", "self", ")", ":", "is_closed", "=", "None", "if", "self", ".", "has_capability", "(", "\"position\"", ")", ":", "is_closed", "=", "self", ".", "cover", ".", "is_closed", "(", ")", "elif", "self", ".", "optimistic", ":", "is_close...
[ 127, 4 ]
[ 134, 24 ]
python
en
['en', 'en', 'en']
True
SomfyCover.current_cover_tilt_position
(self)
Return current position of cover tilt. None is unknown, 0 is closed, 100 is fully open.
Return current position of cover tilt.
def current_cover_tilt_position(self): """Return current position of cover tilt. None is unknown, 0 is closed, 100 is fully open. """ orientation = None if self.has_capability("rotation"): orientation = 100 - self.cover.orientation return orientation
[ "def", "current_cover_tilt_position", "(", "self", ")", ":", "orientation", "=", "None", "if", "self", ".", "has_capability", "(", "\"rotation\"", ")", ":", "orientation", "=", "100", "-", "self", ".", "cover", ".", "orientation", "return", "orientation" ]
[ 137, 4 ]
[ 145, 26 ]
python
en
['en', 'da', 'en']
True
SomfyCover.set_cover_tilt_position
(self, **kwargs)
Move the cover tilt to a specific position.
Move the cover tilt to a specific position.
def set_cover_tilt_position(self, **kwargs): """Move the cover tilt to a specific position.""" self.cover.orientation = 100 - kwargs[ATTR_TILT_POSITION]
[ "def", "set_cover_tilt_position", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "cover", ".", "orientation", "=", "100", "-", "kwargs", "[", "ATTR_TILT_POSITION", "]" ]
[ 147, 4 ]
[ 149, 65 ]
python
en
['en', 'en', 'en']
True
SomfyCover.open_cover_tilt
(self, **kwargs)
Open the cover tilt.
Open the cover tilt.
def open_cover_tilt(self, **kwargs): """Open the cover tilt.""" self.cover.orientation = 0
[ "def", "open_cover_tilt", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "cover", ".", "orientation", "=", "0" ]
[ 151, 4 ]
[ 153, 34 ]
python
en
['en', 'no', 'en']
True
SomfyCover.close_cover_tilt
(self, **kwargs)
Close the cover tilt.
Close the cover tilt.
def close_cover_tilt(self, **kwargs): """Close the cover tilt.""" self.cover.orientation = 100
[ "def", "close_cover_tilt", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "cover", ".", "orientation", "=", "100" ]
[ 155, 4 ]
[ 157, 36 ]
python
en
['en', 'fr', 'en']
True
SomfyCover.stop_cover_tilt
(self, **kwargs)
Stop the cover.
Stop the cover.
def stop_cover_tilt(self, **kwargs): """Stop the cover.""" self.cover.stop()
[ "def", "stop_cover_tilt", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "cover", ".", "stop", "(", ")" ]
[ 159, 4 ]
[ 161, 25 ]
python
en
['en', 'en', 'en']
True
SomfyCover.async_added_to_hass
(self)
Complete the initialization.
Complete the initialization.
async def async_added_to_hass(self): """Complete the initialization.""" await super().async_added_to_hass() if not self.optimistic: return # Restore the last state if we use optimistic last_state = await self.async_get_last_state() if last_state is not None a...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "if", "not", "self", ".", "optimistic", ":", "return", "# Restore the last state if we use optimistic", "last_state", "=", "await", "sel...
[ 163, 4 ]
[ 175, 59 ]
python
en
['en', 'en', 'en']
True
convert_filter
(config: Dict[str, List[str]])
Convert the filter schema into a filter.
Convert the filter schema into a filter.
def convert_filter(config: Dict[str, List[str]]) -> Callable[[str], bool]: """Convert the filter schema into a filter.""" filt = generate_filter( config[CONF_INCLUDE_DOMAINS], config[CONF_INCLUDE_ENTITIES], config[CONF_EXCLUDE_DOMAINS], config[CONF_EXCLUDE_ENTITIES], conf...
[ "def", "convert_filter", "(", "config", ":", "Dict", "[", "str", ",", "List", "[", "str", "]", "]", ")", "->", "Callable", "[", "[", "str", "]", ",", "bool", "]", ":", "filt", "=", "generate_filter", "(", "config", "[", "CONF_INCLUDE_DOMAINS", "]", "...
[ 21, 0 ]
[ 33, 15 ]
python
en
['en', 'lb', 'en']
True
convert_include_exclude_filter
( config: Dict[str, Dict[str, List[str]]] )
Convert the include exclude filter schema into a filter.
Convert the include exclude filter schema into a filter.
def convert_include_exclude_filter( config: Dict[str, Dict[str, List[str]]] ) -> Callable[[str], bool]: """Convert the include exclude filter schema into a filter.""" include = config[CONF_INCLUDE] exclude = config[CONF_EXCLUDE] filt = convert_filter( { CONF_INCLUDE_DOMAINS: incl...
[ "def", "convert_include_exclude_filter", "(", "config", ":", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "List", "[", "str", "]", "]", "]", ")", "->", "Callable", "[", "[", "str", "]", ",", "bool", "]", ":", "include", "=", "config", "[", "CO...
[ 58, 0 ]
[ 75, 15 ]
python
en
['en', 'en', 'en']
True
_glob_to_re
(glob: str)
Translate and compile glob string into pattern.
Translate and compile glob string into pattern.
def _glob_to_re(glob: str) -> Pattern[str]: """Translate and compile glob string into pattern.""" return re.compile(fnmatch.translate(glob))
[ "def", "_glob_to_re", "(", "glob", ":", "str", ")", "->", "Pattern", "[", "str", "]", ":", "return", "re", ".", "compile", "(", "fnmatch", ".", "translate", "(", "glob", ")", ")" ]
[ 104, 0 ]
[ 106, 46 ]
python
en
['en', 'en', 'en']
True
_test_against_patterns
(patterns: List[Pattern[str]], entity_id: str)
Test entity against list of patterns, true if any match.
Test entity against list of patterns, true if any match.
def _test_against_patterns(patterns: List[Pattern[str]], entity_id: str) -> bool: """Test entity against list of patterns, true if any match.""" for pattern in patterns: if pattern.match(entity_id): return True return False
[ "def", "_test_against_patterns", "(", "patterns", ":", "List", "[", "Pattern", "[", "str", "]", "]", ",", "entity_id", ":", "str", ")", "->", "bool", ":", "for", "pattern", "in", "patterns", ":", "if", "pattern", ".", "match", "(", "entity_id", ")", ":...
[ 109, 0 ]
[ 115, 16 ]
python
en
['en', 'en', 'en']
True
generate_filter
( include_domains: List[str], include_entities: List[str], exclude_domains: List[str], exclude_entities: List[str], include_entity_globs: List[str] = [], exclude_entity_globs: List[str] = [], )
Return a function that will filter entities based on the args.
Return a function that will filter entities based on the args.
def generate_filter( include_domains: List[str], include_entities: List[str], exclude_domains: List[str], exclude_entities: List[str], include_entity_globs: List[str] = [], exclude_entity_globs: List[str] = [], ) -> Callable[[str], bool]: """Return a function that will filter entities based ...
[ "def", "generate_filter", "(", "include_domains", ":", "List", "[", "str", "]", ",", "include_entities", ":", "List", "[", "str", "]", ",", "exclude_domains", ":", "List", "[", "str", "]", ",", "exclude_entities", ":", "List", "[", "str", "]", ",", "incl...
[ 120, 0 ]
[ 228, 51 ]
python
en
['en', 'en', 'en']
True
test_send_magic_packet
(hass)
Test of send magic packet service call.
Test of send magic packet service call.
async def test_send_magic_packet(hass): """Test of send magic packet service call.""" with patch("homeassistant.components.wake_on_lan.wakeonlan") as mocked_wakeonlan: mac = "aa:bb:cc:dd:ee:ff" bc_ip = "192.168.255.255" bc_port = 999 await async_setup_component(hass, DOMAIN, {})...
[ "async", "def", "test_send_magic_packet", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.wake_on_lan.wakeonlan\"", ")", "as", "mocked_wakeonlan", ":", "mac", "=", "\"aa:bb:cc:dd:ee:ff\"", "bc_ip", "=", "\"192.168.255.255\"", "bc_port", "=", "99...
[ 10, 0 ]
[ 66, 53 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities )
Set up the HomematicIP cover from a config entry.
Set up the HomematicIP cover from a config entry.
async def async_setup_entry( hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities ) -> None: """Set up the HomematicIP cover from a config entry.""" hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id] entities = [] for device in hap.home.devices: if isinstance(device, Asy...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "config_entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "hap", "=", "hass", ".", "data", "[", "HMIPC_DOMAIN", "]", "[", "config_entry", ".", "unique...
[ 29, 0 ]
[ 50, 36 ]
python
en
['en', 'en', 'en']
True
HomematicipCoverShutter.current_cover_position
(self)
Return current position of cover.
Return current position of cover.
def current_cover_position(self) -> int: """Return current position of cover.""" if self._device.shutterLevel is not None: return int((1 - self._device.shutterLevel) * 100) return None
[ "def", "current_cover_position", "(", "self", ")", "->", "int", ":", "if", "self", ".", "_device", ".", "shutterLevel", "is", "not", "None", ":", "return", "int", "(", "(", "1", "-", "self", ".", "_device", ".", "shutterLevel", ")", "*", "100", ")", ...
[ 57, 4 ]
[ 61, 19 ]
python
en
['en', 'en', 'en']
True
HomematicipCoverShutter.async_set_cover_position
(self, **kwargs)
Move the cover to a specific position.
Move the cover to a specific position.
async def async_set_cover_position(self, **kwargs) -> None: """Move the cover to a specific position.""" position = kwargs[ATTR_POSITION] # HmIP cover is closed:1 -> open:0 level = 1 - position / 100.0 await self._device.set_shutter_level(level)
[ "async", "def", "async_set_cover_position", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "position", "=", "kwargs", "[", "ATTR_POSITION", "]", "# HmIP cover is closed:1 -> open:0", "level", "=", "1", "-", "position", "/", "100.0", "await", "se...
[ 63, 4 ]
[ 68, 51 ]
python
en
['en', 'en', 'en']
True
HomematicipCoverShutter.is_closed
(self)
Return if the cover is closed.
Return if the cover is closed.
def is_closed(self) -> Optional[bool]: """Return if the cover is closed.""" if self._device.shutterLevel is not None: return self._device.shutterLevel == HMIP_COVER_CLOSED return None
[ "def", "is_closed", "(", "self", ")", "->", "Optional", "[", "bool", "]", ":", "if", "self", ".", "_device", ".", "shutterLevel", "is", "not", "None", ":", "return", "self", ".", "_device", ".", "shutterLevel", "==", "HMIP_COVER_CLOSED", "return", "None" ]
[ 71, 4 ]
[ 75, 19 ]
python
en
['en', 'en', 'en']
True
HomematicipCoverShutter.async_open_cover
(self, **kwargs)
Open the cover.
Open the cover.
async def async_open_cover(self, **kwargs) -> None: """Open the cover.""" await self._device.set_shutter_level(HMIP_COVER_OPEN)
[ "async", "def", "async_open_cover", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_device", ".", "set_shutter_level", "(", "HMIP_COVER_OPEN", ")" ]
[ 77, 4 ]
[ 79, 61 ]
python
en
['en', 'en', 'en']
True
HomematicipCoverShutter.async_close_cover
(self, **kwargs)
Close the cover.
Close the cover.
async def async_close_cover(self, **kwargs) -> None: """Close the cover.""" await self._device.set_shutter_level(HMIP_COVER_CLOSED)
[ "async", "def", "async_close_cover", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_device", ".", "set_shutter_level", "(", "HMIP_COVER_CLOSED", ")" ]
[ 81, 4 ]
[ 83, 63 ]
python
en
['en', 'en', 'en']
True
HomematicipCoverShutter.async_stop_cover
(self, **kwargs)
Stop the device if in motion.
Stop the device if in motion.
async def async_stop_cover(self, **kwargs) -> None: """Stop the device if in motion.""" await self._device.set_shutter_stop()
[ "async", "def", "async_stop_cover", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_device", ".", "set_shutter_stop", "(", ")" ]
[ 85, 4 ]
[ 87, 45 ]
python
en
['en', 'en', 'en']
True
HomematicipCoverSlats.current_cover_tilt_position
(self)
Return current tilt position of cover.
Return current tilt position of cover.
def current_cover_tilt_position(self) -> int: """Return current tilt position of cover.""" if self._device.slatsLevel is not None: return int((1 - self._device.slatsLevel) * 100) return None
[ "def", "current_cover_tilt_position", "(", "self", ")", "->", "int", ":", "if", "self", ".", "_device", ".", "slatsLevel", "is", "not", "None", ":", "return", "int", "(", "(", "1", "-", "self", ".", "_device", ".", "slatsLevel", ")", "*", "100", ")", ...
[ 94, 4 ]
[ 98, 19 ]
python
en
['en', 'da', 'en']
True
HomematicipCoverSlats.async_set_cover_tilt_position
(self, **kwargs)
Move the cover to a specific tilt position.
Move the cover to a specific tilt position.
async def async_set_cover_tilt_position(self, **kwargs) -> None: """Move the cover to a specific tilt position.""" position = kwargs[ATTR_TILT_POSITION] # HmIP slats is closed:1 -> open:0 level = 1 - position / 100.0 await self._device.set_slats_level(level)
[ "async", "def", "async_set_cover_tilt_position", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "position", "=", "kwargs", "[", "ATTR_TILT_POSITION", "]", "# HmIP slats is closed:1 -> open:0", "level", "=", "1", "-", "position", "/", "100.0", "awa...
[ 100, 4 ]
[ 105, 49 ]
python
en
['en', 'en', 'en']
True
HomematicipCoverSlats.async_open_cover_tilt
(self, **kwargs)
Open the slats.
Open the slats.
async def async_open_cover_tilt(self, **kwargs) -> None: """Open the slats.""" await self._device.set_slats_level(HMIP_SLATS_OPEN)
[ "async", "def", "async_open_cover_tilt", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_device", ".", "set_slats_level", "(", "HMIP_SLATS_OPEN", ")" ]
[ 107, 4 ]
[ 109, 59 ]
python
en
['en', 'st', 'en']
True