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_dehumidifier_set_mode | (hass, utcnow) | Test that we can set the mode of a HomeKit dehumidifier accessory. | Test that we can set the mode of a HomeKit dehumidifier accessory. | async def test_dehumidifier_set_mode(hass, utcnow):
"""Test that we can set the mode of a HomeKit dehumidifier accessory."""
helper = await setup_test_component(hass, create_dehumidifier_service)
await hass.services.async_call(
DOMAIN,
"set_mode",
{"entity_id": helper.entity_id, "mo... | [
"async",
"def",
"test_dehumidifier_set_mode",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_dehumidifier_service",
")",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"\"... | [
208,
0
] | [
228,
52
] | python | en | ['en', 'en', 'en'] | True |
test_humidifier_read_only_mode | (hass, utcnow) | Test that we can read the state of a HomeKit humidifier accessory. | Test that we can read the state of a HomeKit humidifier accessory. | async def test_humidifier_read_only_mode(hass, utcnow):
"""Test that we can read the state of a HomeKit humidifier accessory."""
helper = await setup_test_component(hass, create_humidifier_service)
state = await helper.poll_and_get_state()
assert state.attributes["mode"] == "normal"
helper.charact... | [
"async",
"def",
"test_humidifier_read_only_mode",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_humidifier_service",
")",
"state",
"=",
"await",
"helper",
".",
"poll_and_get_state",
"(",
")",
"asser... | [
231,
0
] | [
252,
47
] | python | en | ['en', 'en', 'en'] | True |
test_dehumidifier_read_only_mode | (hass, utcnow) | Test that we can read the state of a HomeKit dehumidifier accessory. | Test that we can read the state of a HomeKit dehumidifier accessory. | async def test_dehumidifier_read_only_mode(hass, utcnow):
"""Test that we can read the state of a HomeKit dehumidifier accessory."""
helper = await setup_test_component(hass, create_dehumidifier_service)
state = await helper.poll_and_get_state()
assert state.attributes["mode"] == "normal"
helper.c... | [
"async",
"def",
"test_dehumidifier_read_only_mode",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_dehumidifier_service",
")",
"state",
"=",
"await",
"helper",
".",
"poll_and_get_state",
"(",
")",
"a... | [
255,
0
] | [
276,
47
] | python | en | ['en', 'en', 'en'] | True |
test_humidifier_target_humidity_modes | (hass, utcnow) | Test that we can read the state of a HomeKit humidifier accessory. | Test that we can read the state of a HomeKit humidifier accessory. | async def test_humidifier_target_humidity_modes(hass, utcnow):
"""Test that we can read the state of a HomeKit humidifier accessory."""
helper = await setup_test_component(hass, create_humidifier_service)
helper.characteristics[RELATIVE_HUMIDITY_HUMIDIFIER_THRESHOLD].value = 37
helper.characteristics[R... | [
"async",
"def",
"test_humidifier_target_humidity_modes",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_humidifier_service",
")",
"helper",
".",
"characteristics",
"[",
"RELATIVE_HUMIDITY_HUMIDIFIER_THRESHOL... | [
279,
0
] | [
304,
45
] | python | en | ['en', 'en', 'en'] | True |
test_dehumidifier_target_humidity_modes | (hass, utcnow) | Test that we can read the state of a HomeKit dehumidifier accessory. | Test that we can read the state of a HomeKit dehumidifier accessory. | async def test_dehumidifier_target_humidity_modes(hass, utcnow):
"""Test that we can read the state of a HomeKit dehumidifier accessory."""
helper = await setup_test_component(hass, create_dehumidifier_service)
helper.characteristics[RELATIVE_HUMIDITY_DEHUMIDIFIER_THRESHOLD].value = 73
helper.character... | [
"async",
"def",
"test_dehumidifier_target_humidity_modes",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_dehumidifier_service",
")",
"helper",
".",
"characteristics",
"[",
"RELATIVE_HUMIDITY_DEHUMIDIFIER_TH... | [
307,
0
] | [
332,
45
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, yaml_config: Dict[str, Any]) | Activate Google Actions component. | Activate Google Actions component. | async def async_setup(hass: HomeAssistant, yaml_config: Dict[str, Any]):
"""Activate Google Actions component."""
config = yaml_config.get(DOMAIN, {})
google_config = GoogleConfig(hass, config)
await google_config.async_initialize()
hass.http.register_view(GoogleAssistantView(google_config))
... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"yaml_config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
":",
"config",
"=",
"yaml_config",
".",
"get",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"google_config",
"=",
"GoogleConfig",
... | [
90,
0
] | [
120,
15
] | python | en | ['en', 'en', 'en'] | True |
test_form | (hass) | Test we get the form and can setup from user input. | Test we get the form and can setup from user input. | async def test_form(hass):
"""Test we get the form and can setup from user input."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "f... | [
"async",
"def",
"test_form",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(... | [
21,
0
] | [
64,
48
] | python | en | ['en', 'en', 'en'] | True |
test_form_import | (hass) | Test we can import the sensor platform config. | Test we can import the sensor platform config. | async def test_form_import(hass):
"""Test we can import the sensor platform config."""
await setup.async_setup_component(hass, "persistent_notification", {})
mock_flume_device_list = _get_mocked_flume_device_list()
with patch(
"homeassistant.components.flume.config_flow.FlumeAuth",
retu... | [
"async",
"def",
"test_form_import",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"mock_flume_device_list",
"=",
"_get_mocked_flume_device_list",
"(",
")",
"with",
"patch",... | [
67,
0
] | [
105,
48
] | python | en | ['en', 'da', 'en'] | True |
test_form_invalid_auth | (hass) | Test we handle invalid auth. | Test we handle invalid auth. | async def test_form_invalid_auth(hass):
"""Test we handle invalid auth."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"homeassistant.components.flume.config_flow.FlumeAuth",
return_value=True,
), p... | [
"async",
"def",
"test_form_invalid_auth",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
")"... | [
108,
0
] | [
132,
56
] | python | en | ['en', 'en', 'en'] | True |
test_form_cannot_connect | (hass) | Test we handle cannot connect error. | Test we handle cannot connect error. | async def test_form_cannot_connect(hass):
"""Test we handle cannot connect error."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"homeassistant.components.flume.config_flow.FlumeAuth",
return_value=True,... | [
"async",
"def",
"test_form_cannot_connect",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
"... | [
135,
0
] | [
158,
58
] | python | en | ['en', 'en', 'en'] | True |
async_attach_trigger | (hass, config, action, automation_info) | Listen for events based on configuration. | Listen for events based on configuration. | async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for events based on configuration."""
number = config.get(CONF_NUMBER)
held_more_than = config.get(CONF_HELD_MORE_THAN)
held_less_than = config.get(CONF_HELD_LESS_THAN)
pressed_time = None
cancel_pressed_more_than =... | [
"async",
"def",
"async_attach_trigger",
"(",
"hass",
",",
"config",
",",
"action",
",",
"automation_info",
")",
":",
"number",
"=",
"config",
".",
"get",
"(",
"CONF_NUMBER",
")",
"held_more_than",
"=",
"config",
".",
"get",
"(",
"CONF_HELD_MORE_THAN",
")",
"... | [
29,
0
] | [
101,
23
] | python | en | ['en', 'en', 'en'] | True |
test_form | (hass) | Test we get the form. | Test we get the form. | async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
assert result["errors... | [
"async",
"def",
"test_form",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(... | [
9,
0
] | [
37,
48
] | python | en | ['en', 'en', 'en'] | True |
test_form_cannot_connect | (hass) | Test we handle cannot connect error. | Test we handle cannot connect error. | async def test_form_cannot_connect(hass):
"""Test we handle cannot connect error."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"homeassistant.components.griddy.config_flow.AsyncGriddy.async_getnow",
s... | [
"async",
"def",
"test_form_cannot_connect",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
"... | [
40,
0
] | [
56,
58
] | python | en | ['en', 'en', 'en'] | True |
test_fetch_period_api | (hass, hass_client) | Test the fetch period view for history. | Test the fetch period view for history. | async def test_fetch_period_api(hass, hass_client):
"""Test the fetch period view for history."""
await hass.async_add_executor_job(init_recorder_component, hass)
await async_setup_component(hass, "history", {})
await hass.async_add_executor_job(hass.data[recorder.DATA_INSTANCE].block_till_done)
cli... | [
"async",
"def",
"test_fetch_period_api",
"(",
"hass",
",",
"hass_client",
")",
":",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"init_recorder_component",
",",
"hass",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"history\"",
",",
"{",
"}",
... | [
761,
0
] | [
768,
33
] | python | en | ['en', 'en', 'en'] | True |
test_fetch_period_api_with_use_include_order | (hass, hass_client) | Test the fetch period view for history with include order. | Test the fetch period view for history with include order. | async def test_fetch_period_api_with_use_include_order(hass, hass_client):
"""Test the fetch period view for history with include order."""
await hass.async_add_executor_job(init_recorder_component, hass)
await async_setup_component(
hass, "history", {history.DOMAIN: {history.CONF_ORDER: True}}
... | [
"async",
"def",
"test_fetch_period_api_with_use_include_order",
"(",
"hass",
",",
"hass_client",
")",
":",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"init_recorder_component",
",",
"hass",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"history\""... | [
771,
0
] | [
780,
33
] | python | en | ['en', 'en', 'en'] | True |
test_fetch_period_api_with_minimal_response | (hass, hass_client) | Test the fetch period view for history with minimal_response. | Test the fetch period view for history with minimal_response. | async def test_fetch_period_api_with_minimal_response(hass, hass_client):
"""Test the fetch period view for history with minimal_response."""
await hass.async_add_executor_job(init_recorder_component, hass)
await async_setup_component(hass, "history", {})
await hass.async_add_executor_job(hass.data[reco... | [
"async",
"def",
"test_fetch_period_api_with_minimal_response",
"(",
"hass",
",",
"hass_client",
")",
":",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"init_recorder_component",
",",
"hass",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"history\"",... | [
783,
0
] | [
792,
33
] | python | en | ['en', 'en', 'en'] | True |
test_fetch_period_api_with_no_timestamp | (hass, hass_client) | Test the fetch period view for history with no timestamp. | Test the fetch period view for history with no timestamp. | async def test_fetch_period_api_with_no_timestamp(hass, hass_client):
"""Test the fetch period view for history with no timestamp."""
await hass.async_add_executor_job(init_recorder_component, hass)
await async_setup_component(hass, "history", {})
await hass.async_add_executor_job(hass.data[recorder.DAT... | [
"async",
"def",
"test_fetch_period_api_with_no_timestamp",
"(",
"hass",
",",
"hass_client",
")",
":",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"init_recorder_component",
",",
"hass",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"history\"",
"... | [
795,
0
] | [
802,
33
] | python | en | ['en', 'en', 'en'] | True |
test_fetch_period_api_with_include_order | (hass, hass_client) | Test the fetch period view for history. | Test the fetch period view for history. | async def test_fetch_period_api_with_include_order(hass, hass_client):
"""Test the fetch period view for history."""
await hass.async_add_executor_job(init_recorder_component, hass)
await async_setup_component(
hass,
"history",
{
"history": {
"use_include_... | [
"async",
"def",
"test_fetch_period_api_with_include_order",
"(",
"hass",
",",
"hass_client",
")",
":",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"init_recorder_component",
",",
"hass",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"history\"",
... | [
805,
0
] | [
824,
33
] | python | en | ['en', 'en', 'en'] | True |
test_fetch_period_api_with_entity_glob_include | (hass, hass_client) | Test the fetch period view for history. | Test the fetch period view for history. | async def test_fetch_period_api_with_entity_glob_include(hass, hass_client):
"""Test the fetch period view for history."""
await hass.async_add_executor_job(init_recorder_component, hass)
await async_setup_component(
hass,
"history",
{
"history": {
"includ... | [
"async",
"def",
"test_fetch_period_api_with_entity_glob_include",
"(",
"hass",
",",
"hass_client",
")",
":",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"init_recorder_component",
",",
"hass",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"history\... | [
827,
0
] | [
856,
62
] | python | en | ['en', 'en', 'en'] | True |
test_fetch_period_api_with_entity_glob_exclude | (hass, hass_client) | Test the fetch period view for history. | Test the fetch period view for history. | async def test_fetch_period_api_with_entity_glob_exclude(hass, hass_client):
"""Test the fetch period view for history."""
await hass.async_add_executor_job(init_recorder_component, hass)
await async_setup_component(
hass,
"history",
{
"history": {
"exclud... | [
"async",
"def",
"test_fetch_period_api_with_entity_glob_exclude",
"(",
"hass",
",",
"hass_client",
")",
":",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"init_recorder_component",
",",
"hass",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"history\... | [
859,
0
] | [
896,
60
] | python | en | ['en', 'en', 'en'] | True |
test_fetch_period_api_with_entity_glob_include_and_exclude | (hass, hass_client) | Test the fetch period view for history. | Test the fetch period view for history. | async def test_fetch_period_api_with_entity_glob_include_and_exclude(hass, hass_client):
"""Test the fetch period view for history."""
await hass.async_add_executor_job(init_recorder_component, hass)
await async_setup_component(
hass,
"history",
{
"history": {
... | [
"async",
"def",
"test_fetch_period_api_with_entity_glob_include_and_exclude",
"(",
"hass",
",",
"hass_client",
")",
":",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"init_recorder_component",
",",
"hass",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
... | [
899,
0
] | [
941,
61
] | python | en | ['en', 'en', 'en'] | True |
test_entity_ids_limit_via_api | (hass, hass_client) | Test limiting history to entity_ids. | Test limiting history to entity_ids. | async def test_entity_ids_limit_via_api(hass, hass_client):
"""Test limiting history to entity_ids."""
await hass.async_add_executor_job(init_recorder_component, hass)
await async_setup_component(
hass,
"history",
{"history": {}},
)
await hass.async_add_executor_job(hass.data... | [
"async",
"def",
"test_entity_ids_limit_via_api",
"(",
"hass",
",",
"hass_client",
")",
":",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"init_recorder_component",
",",
"hass",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"history\"",
",",
"{",... | [
944,
0
] | [
971,
58
] | python | en | ['en', 'en', 'en'] | True |
test_entity_ids_limit_via_api_with_skip_initial_state | (hass, hass_client) | Test limiting history to entity_ids with skip_initial_state. | Test limiting history to entity_ids with skip_initial_state. | async def test_entity_ids_limit_via_api_with_skip_initial_state(hass, hass_client):
"""Test limiting history to entity_ids with skip_initial_state."""
await hass.async_add_executor_job(init_recorder_component, hass)
await async_setup_component(
hass,
"history",
{"history": {}},
)... | [
"async",
"def",
"test_entity_ids_limit_via_api_with_skip_initial_state",
"(",
"hass",
",",
"hass_client",
")",
":",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"init_recorder_component",
",",
"hass",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"h... | [
974,
0
] | [
1009,
58
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.setUp | (self) | Set up things to be run when tests are started. | Set up things to be run when tests are started. | def setUp(self): # pylint: disable=invalid-name
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.addCleanup(self.tear_down_cleanup) | [
"def",
"setUp",
"(",
"self",
")",
":",
"# pylint: disable=invalid-name",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")",
"self",
".",
"addCleanup",
"(",
"self",
".",
"tear_down_cleanup",
")"
] | [
26,
4
] | [
29,
47
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.tear_down_cleanup | (self) | Stop everything that was started. | Stop everything that was started. | def tear_down_cleanup(self):
"""Stop everything that was started."""
self.hass.stop() | [
"def",
"tear_down_cleanup",
"(",
"self",
")",
":",
"self",
".",
"hass",
".",
"stop",
"(",
")"
] | [
31,
4
] | [
33,
24
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.init_recorder | (self) | Initialize the recorder. | Initialize the recorder. | def init_recorder(self):
"""Initialize the recorder."""
init_recorder_component(self.hass)
self.hass.start()
wait_recording_done(self.hass) | [
"def",
"init_recorder",
"(",
"self",
")",
":",
"init_recorder_component",
"(",
"self",
".",
"hass",
")",
"self",
".",
"hass",
".",
"start",
"(",
")",
"wait_recording_done",
"(",
"self",
".",
"hass",
")"
] | [
35,
4
] | [
39,
38
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_setup | (self) | Test setup method of history. | Test setup method of history. | def test_setup(self):
"""Test setup method of history."""
config = history.CONFIG_SCHEMA(
{
# ha.DOMAIN: {},
history.DOMAIN: {
history.CONF_INCLUDE: {
history.CONF_DOMAINS: ["media_player"],
h... | [
"def",
"test_setup",
"(",
"self",
")",
":",
"config",
"=",
"history",
".",
"CONFIG_SCHEMA",
"(",
"{",
"# ha.DOMAIN: {},",
"history",
".",
"DOMAIN",
":",
"{",
"history",
".",
"CONF_INCLUDE",
":",
"{",
"history",
".",
"CONF_DOMAINS",
":",
"[",
"\"media_player\... | [
41,
4
] | [
59,
65
] | python | en | ['en', 'et', 'en'] | True |
TestComponentHistory.test_get_states | (self) | Test getting states at a specific point in time. | Test getting states at a specific point in time. | def test_get_states(self):
"""Test getting states at a specific point in time."""
self.test_setup()
states = []
now = dt_util.utcnow()
with patch(
"homeassistant.components.recorder.dt_util.utcnow", return_value=now
):
for i in range(5):
... | [
"def",
"test_get_states",
"(",
"self",
")",
":",
"self",
".",
"test_setup",
"(",
")",
"states",
"=",
"[",
"]",
"now",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"with",
"patch",
"(",
"\"homeassistant.components.recorder.dt_util.utcnow\"",
",",
"return_value",
"=... | [
61,
4
] | [
113,
88
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_state_changes_during_period | (self) | Test state change during period. | Test state change during period. | def test_state_changes_during_period(self):
"""Test state change during period."""
self.test_setup()
entity_id = "media_player.test"
def set_state(state):
"""Set the state."""
self.hass.states.set(entity_id, state)
wait_recording_done(self.hass)
... | [
"def",
"test_state_changes_during_period",
"(",
"self",
")",
":",
"self",
".",
"test_setup",
"(",
")",
"entity_id",
"=",
"\"media_player.test\"",
"def",
"set_state",
"(",
"state",
")",
":",
"\"\"\"Set the state.\"\"\"",
"self",
".",
"hass",
".",
"states",
".",
"... | [
115,
4
] | [
154,
40
] | python | en | ['fr', 'en', 'en'] | True |
TestComponentHistory.test_get_last_state_changes | (self) | Test number of state changes. | Test number of state changes. | def test_get_last_state_changes(self):
"""Test number of state changes."""
self.test_setup()
entity_id = "sensor.test"
def set_state(state):
"""Set the state."""
self.hass.states.set(entity_id, state)
wait_recording_done(self.hass)
return ... | [
"def",
"test_get_last_state_changes",
"(",
"self",
")",
":",
"self",
".",
"test_setup",
"(",
")",
"entity_id",
"=",
"\"sensor.test\"",
"def",
"set_state",
"(",
"state",
")",
":",
"\"\"\"Set the state.\"\"\"",
"self",
".",
"hass",
".",
"states",
".",
"set",
"("... | [
156,
4
] | [
189,
40
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_ensure_state_can_be_copied | (self) | Ensure a state can pass though copy().
The filter integration uses copy() on states
from history.
| Ensure a state can pass though copy(). | def test_ensure_state_can_be_copied(self):
"""Ensure a state can pass though copy().
The filter integration uses copy() on states
from history.
"""
self.test_setup()
entity_id = "sensor.test"
def set_state(state):
"""Set the state."""
sel... | [
"def",
"test_ensure_state_can_be_copied",
"(",
"self",
")",
":",
"self",
".",
"test_setup",
"(",
")",
"entity_id",
"=",
"\"sensor.test\"",
"def",
"set_state",
"(",
"state",
")",
":",
"\"\"\"Set the state.\"\"\"",
"self",
".",
"hass",
".",
"states",
".",
"set",
... | [
191,
4
] | [
222,
61
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_get_significant_states | (self) | Test that only significant states are returned.
We should get back every thermostat change that
includes an attribute change, but only the state updates for
media player (attribute changes are not significant and not returned).
| Test that only significant states are returned. | def test_get_significant_states(self):
"""Test that only significant states are returned.
We should get back every thermostat change that
includes an attribute change, but only the state updates for
media player (attribute changes are not significant and not returned).
"""
... | [
"def",
"test_get_significant_states",
"(",
"self",
")",
":",
"zero",
",",
"four",
",",
"states",
"=",
"self",
".",
"record_states",
"(",
")",
"hist",
"=",
"history",
".",
"get_significant_states",
"(",
"self",
".",
"hass",
",",
"zero",
",",
"four",
",",
... | [
224,
4
] | [
235,
29
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_get_significant_states_minimal_response | (self) | Test that only significant states are returned.
When minimal responses is set only the first and
last states return a complete state.
We should get back every thermostat change that
includes an attribute change, but only the state updates for
media player (attribute changes are... | Test that only significant states are returned. | def test_get_significant_states_minimal_response(self):
"""Test that only significant states are returned.
When minimal responses is set only the first and
last states return a complete state.
We should get back every thermostat change that
includes an attribute change, but onl... | [
"def",
"test_get_significant_states_minimal_response",
"(",
"self",
")",
":",
"zero",
",",
"four",
",",
"states",
"=",
"self",
".",
"record_states",
"(",
")",
"hist",
"=",
"history",
".",
"get_significant_states",
"(",
"self",
".",
"hass",
",",
"zero",
",",
... | [
237,
4
] | [
268,
29
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_get_significant_states_with_initial | (self) | Test that only significant states are returned.
We should get back every thermostat change that
includes an attribute change, but only the state updates for
media player (attribute changes are not significant and not returned).
| Test that only significant states are returned. | def test_get_significant_states_with_initial(self):
"""Test that only significant states are returned.
We should get back every thermostat change that
includes an attribute change, but only the state updates for
media player (attribute changes are not significant and not returned).
... | [
"def",
"test_get_significant_states_with_initial",
"(",
"self",
")",
":",
"zero",
",",
"four",
",",
"states",
"=",
"self",
".",
"record_states",
"(",
")",
"one",
"=",
"zero",
"+",
"timedelta",
"(",
"seconds",
"=",
"1",
")",
"one_and_half",
"=",
"zero",
"+"... | [
270,
4
] | [
294,
29
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_get_significant_states_without_initial | (self) | Test that only significant states are returned.
We should get back every thermostat change that
includes an attribute change, but only the state updates for
media player (attribute changes are not significant and not returned).
| Test that only significant states are returned. | def test_get_significant_states_without_initial(self):
"""Test that only significant states are returned.
We should get back every thermostat change that
includes an attribute change, but only the state updates for
media player (attribute changes are not significant and not returned).
... | [
"def",
"test_get_significant_states_without_initial",
"(",
"self",
")",
":",
"zero",
",",
"four",
",",
"states",
"=",
"self",
".",
"record_states",
"(",
")",
"one",
"=",
"zero",
"+",
"timedelta",
"(",
"seconds",
"=",
"1",
")",
"one_and_half",
"=",
"zero",
... | [
296,
4
] | [
319,
29
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_get_significant_states_entity_id | (self) | Test that only significant states are returned for one entity. | Test that only significant states are returned for one entity. | def test_get_significant_states_entity_id(self):
"""Test that only significant states are returned for one entity."""
zero, four, states = self.record_states()
del states["media_player.test2"]
del states["media_player.test3"]
del states["thermostat.test"]
del states["ther... | [
"def",
"test_get_significant_states_entity_id",
"(",
"self",
")",
":",
"zero",
",",
"four",
",",
"states",
"=",
"self",
".",
"record_states",
"(",
")",
"del",
"states",
"[",
"\"media_player.test2\"",
"]",
"del",
"states",
"[",
"\"media_player.test3\"",
"]",
"del... | [
321,
4
] | [
333,
29
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_get_significant_states_multiple_entity_ids | (self) | Test that only significant states are returned for one entity. | Test that only significant states are returned for one entity. | def test_get_significant_states_multiple_entity_ids(self):
"""Test that only significant states are returned for one entity."""
zero, four, states = self.record_states()
del states["media_player.test2"]
del states["media_player.test3"]
del states["thermostat.test2"]
del s... | [
"def",
"test_get_significant_states_multiple_entity_ids",
"(",
"self",
")",
":",
"zero",
",",
"four",
",",
"states",
"=",
"self",
".",
"record_states",
"(",
")",
"del",
"states",
"[",
"\"media_player.test2\"",
"]",
"del",
"states",
"[",
"\"media_player.test3\"",
"... | [
335,
4
] | [
350,
29
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_get_significant_states_exclude_domain | (self) | Test if significant states are returned when excluding domains.
We should get back every thermostat change that includes an attribute
change, but no media player changes.
| Test if significant states are returned when excluding domains. | def test_get_significant_states_exclude_domain(self):
"""Test if significant states are returned when excluding domains.
We should get back every thermostat change that includes an attribute
change, but no media player changes.
"""
zero, four, states = self.record_states()
... | [
"def",
"test_get_significant_states_exclude_domain",
"(",
"self",
")",
":",
"zero",
",",
"four",
",",
"states",
"=",
"self",
".",
"record_states",
"(",
")",
"del",
"states",
"[",
"\"media_player.test\"",
"]",
"del",
"states",
"[",
"\"media_player.test2\"",
"]",
... | [
352,
4
] | [
371,
65
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_get_significant_states_exclude_entity | (self) | Test if significant states are returned when excluding entities.
We should get back every thermostat and script changes, but no media
player changes.
| Test if significant states are returned when excluding entities. | def test_get_significant_states_exclude_entity(self):
"""Test if significant states are returned when excluding entities.
We should get back every thermostat and script changes, but no media
player changes.
"""
zero, four, states = self.record_states()
del states["media_... | [
"def",
"test_get_significant_states_exclude_entity",
"(",
"self",
")",
":",
"zero",
",",
"four",
",",
"states",
"=",
"self",
".",
"record_states",
"(",
")",
"del",
"states",
"[",
"\"media_player.test\"",
"]",
"config",
"=",
"history",
".",
"CONFIG_SCHEMA",
"(",
... | [
373,
4
] | [
390,
65
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_get_significant_states_exclude | (self) | Test significant states when excluding entities and domains.
We should not get back every thermostat and media player test changes.
| Test significant states when excluding entities and domains. | def test_get_significant_states_exclude(self):
"""Test significant states when excluding entities and domains.
We should not get back every thermostat and media player test changes.
"""
zero, four, states = self.record_states()
del states["media_player.test"]
del states[... | [
"def",
"test_get_significant_states_exclude",
"(",
"self",
")",
":",
"zero",
",",
"four",
",",
"states",
"=",
"self",
".",
"record_states",
"(",
")",
"del",
"states",
"[",
"\"media_player.test\"",
"]",
"del",
"states",
"[",
"\"thermostat.test\"",
"]",
"del",
"... | [
392,
4
] | [
413,
65
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_get_significant_states_exclude_include_entity | (self) | Test significant states when excluding domains and include entities.
We should not get back every thermostat and media player test changes.
| Test significant states when excluding domains and include entities. | def test_get_significant_states_exclude_include_entity(self):
"""Test significant states when excluding domains and include entities.
We should not get back every thermostat and media player test changes.
"""
zero, four, states = self.record_states()
del states["media_player.tes... | [
"def",
"test_get_significant_states_exclude_include_entity",
"(",
"self",
")",
":",
"zero",
",",
"four",
",",
"states",
"=",
"self",
".",
"record_states",
"(",
")",
"del",
"states",
"[",
"\"media_player.test2\"",
"]",
"del",
"states",
"[",
"\"media_player.test3\"",
... | [
415,
4
] | [
438,
65
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_get_significant_states_include_domain | (self) | Test if significant states are returned when including domains.
We should get back every thermostat and script changes, but no media
player changes.
| Test if significant states are returned when including domains. | def test_get_significant_states_include_domain(self):
"""Test if significant states are returned when including domains.
We should get back every thermostat and script changes, but no media
player changes.
"""
zero, four, states = self.record_states()
del states["media_p... | [
"def",
"test_get_significant_states_include_domain",
"(",
"self",
")",
":",
"zero",
",",
"four",
",",
"states",
"=",
"self",
".",
"record_states",
"(",
")",
"del",
"states",
"[",
"\"media_player.test\"",
"]",
"del",
"states",
"[",
"\"media_player.test2\"",
"]",
... | [
440,
4
] | [
461,
65
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_get_significant_states_include_entity | (self) | Test if significant states are returned when including entities.
We should only get back changes of the media_player.test entity.
| Test if significant states are returned when including entities. | def test_get_significant_states_include_entity(self):
"""Test if significant states are returned when including entities.
We should only get back changes of the media_player.test entity.
"""
zero, four, states = self.record_states()
del states["media_player.test2"]
del s... | [
"def",
"test_get_significant_states_include_entity",
"(",
"self",
")",
":",
"zero",
",",
"four",
",",
"states",
"=",
"self",
".",
"record_states",
"(",
")",
"del",
"states",
"[",
"\"media_player.test2\"",
"]",
"del",
"states",
"[",
"\"media_player.test3\"",
"]",
... | [
463,
4
] | [
483,
65
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_get_significant_states_include | (self) | Test significant states when including domains and entities.
We should only get back changes of the media_player.test entity and the
thermostat domain.
| Test significant states when including domains and entities. | def test_get_significant_states_include(self):
"""Test significant states when including domains and entities.
We should only get back changes of the media_player.test entity and the
thermostat domain.
"""
zero, four, states = self.record_states()
del states["media_playe... | [
"def",
"test_get_significant_states_include",
"(",
"self",
")",
":",
"zero",
",",
"four",
",",
"states",
"=",
"self",
".",
"record_states",
"(",
")",
"del",
"states",
"[",
"\"media_player.test2\"",
"]",
"del",
"states",
"[",
"\"media_player.test3\"",
"]",
"del",... | [
485,
4
] | [
507,
65
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_get_significant_states_include_exclude_domain | (self) | Test if significant states when excluding and including domains.
We should not get back any changes since we include only the
media_player domain but also exclude it.
| Test if significant states when excluding and including domains. | def test_get_significant_states_include_exclude_domain(self):
"""Test if significant states when excluding and including domains.
We should not get back any changes since we include only the
media_player domain but also exclude it.
"""
zero, four, states = self.record_states()
... | [
"def",
"test_get_significant_states_include_exclude_domain",
"(",
"self",
")",
":",
"zero",
",",
"four",
",",
"states",
"=",
"self",
".",
"record_states",
"(",
")",
"del",
"states",
"[",
"\"media_player.test\"",
"]",
"del",
"states",
"[",
"\"media_player.test2\"",
... | [
509,
4
] | [
532,
65
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_get_significant_states_include_exclude_entity | (self) | Test if significant states when excluding and including domains.
We should not get back any changes since we include only
media_player.test but also exclude it.
| Test if significant states when excluding and including domains. | def test_get_significant_states_include_exclude_entity(self):
"""Test if significant states when excluding and including domains.
We should not get back any changes since we include only
media_player.test but also exclude it.
"""
zero, four, states = self.record_states()
... | [
"def",
"test_get_significant_states_include_exclude_entity",
"(",
"self",
")",
":",
"zero",
",",
"four",
",",
"states",
"=",
"self",
".",
"record_states",
"(",
")",
"del",
"states",
"[",
"\"media_player.test\"",
"]",
"del",
"states",
"[",
"\"media_player.test2\"",
... | [
534,
4
] | [
561,
65
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_get_significant_states_include_exclude | (self) | Test if significant states when in/excluding domains and entities.
We should only get back changes of the media_player.test2 entity.
| Test if significant states when in/excluding domains and entities. | def test_get_significant_states_include_exclude(self):
"""Test if significant states when in/excluding domains and entities.
We should only get back changes of the media_player.test2 entity.
"""
zero, four, states = self.record_states()
del states["media_player.test"]
de... | [
"def",
"test_get_significant_states_include_exclude",
"(",
"self",
")",
":",
"zero",
",",
"four",
",",
"states",
"=",
"self",
".",
"record_states",
"(",
")",
"del",
"states",
"[",
"\"media_player.test\"",
"]",
"del",
"states",
"[",
"\"thermostat.test\"",
"]",
"d... | [
563,
4
] | [
589,
65
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_get_significant_states_are_ordered | (self) | Test order of results from get_significant_states.
When entity ids are given, the results should be returned with the data
in the same order.
| Test order of results from get_significant_states. | def test_get_significant_states_are_ordered(self):
"""Test order of results from get_significant_states.
When entity ids are given, the results should be returned with the data
in the same order.
"""
zero, four, states = self.record_states()
entity_ids = ["media_player.t... | [
"def",
"test_get_significant_states_are_ordered",
"(",
"self",
")",
":",
"zero",
",",
"four",
",",
"states",
"=",
"self",
".",
"record_states",
"(",
")",
"entity_ids",
"=",
"[",
"\"media_player.test\"",
",",
"\"media_player.test2\"",
"]",
"hist",
"=",
"history",
... | [
591,
4
] | [
607,
46
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.test_get_significant_states_only | (self) | Test significant states when significant_states_only is set. | Test significant states when significant_states_only is set. | def test_get_significant_states_only(self):
"""Test significant states when significant_states_only is set."""
self.test_setup()
entity_id = "sensor.test"
def set_state(state, **kwargs):
"""Set the state."""
self.hass.states.set(entity_id, state, **kwargs)
... | [
"def",
"test_get_significant_states_only",
"(",
"self",
")",
":",
"self",
".",
"test_setup",
"(",
")",
"entity_id",
"=",
"\"sensor.test\"",
"def",
"set_state",
"(",
"state",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Set the state.\"\"\"",
"self",
".",
"hass",
... | [
609,
4
] | [
663,
40
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.check_significant_states | (self, zero, four, states, config) | Check if significant states are retrieved. | Check if significant states are retrieved. | def check_significant_states(self, zero, four, states, config):
"""Check if significant states are retrieved."""
filters = history.Filters()
exclude = config[history.DOMAIN].get(history.CONF_EXCLUDE)
if exclude:
filters.excluded_entities = exclude.get(history.CONF_ENTITIES, [... | [
"def",
"check_significant_states",
"(",
"self",
",",
"zero",
",",
"four",
",",
"states",
",",
"config",
")",
":",
"filters",
"=",
"history",
".",
"Filters",
"(",
")",
"exclude",
"=",
"config",
"[",
"history",
".",
"DOMAIN",
"]",
".",
"get",
"(",
"histo... | [
665,
4
] | [
678,
29
] | python | en | ['en', 'en', 'en'] | True |
TestComponentHistory.record_states | (self) | Record some test states.
We inject a bunch of state updates from media player, zone and
thermostat.
| Record some test states. | def record_states(self):
"""Record some test states.
We inject a bunch of state updates from media player, zone and
thermostat.
"""
self.test_setup()
mp = "media_player.test"
mp2 = "media_player.test2"
mp3 = "media_player.test3"
therm = "thermosta... | [
"def",
"record_states",
"(",
"self",
")",
":",
"self",
".",
"test_setup",
"(",
")",
"mp",
"=",
"\"media_player.test\"",
"mp2",
"=",
"\"media_player.test2\"",
"mp3",
"=",
"\"media_player.test3\"",
"therm",
"=",
"\"thermostat.test\"",
"therm2",
"=",
"\"thermostat.test... | [
680,
4
] | [
758,
33
] | python | en | ['en', 'en', 'en'] | True |
IHCDevice.__init__ | (
self, ihc_controller, name, ihc_id: int, info: bool, product=None
) | Initialize IHC attributes. | Initialize IHC attributes. | def __init__(
self, ihc_controller, name, ihc_id: int, info: bool, product=None
) -> None:
"""Initialize IHC attributes."""
self.ihc_controller = ihc_controller
self._name = name
self.ihc_id = ihc_id
self.info = info
if product:
self.ihc_name = pro... | [
"def",
"__init__",
"(",
"self",
",",
"ihc_controller",
",",
"name",
",",
"ihc_id",
":",
"int",
",",
"info",
":",
"bool",
",",
"product",
"=",
"None",
")",
"->",
"None",
":",
"self",
".",
"ihc_controller",
"=",
"ihc_controller",
"self",
".",
"_name",
"=... | [
12,
4
] | [
27,
34
] | python | en | ['en', 'co', 'en'] | True |
IHCDevice.async_added_to_hass | (self) | Add callback for IHC changes. | Add callback for IHC changes. | async def async_added_to_hass(self):
"""Add callback for IHC changes."""
self.ihc_controller.add_notify_event(self.ihc_id, self.on_ihc_change, True) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"ihc_controller",
".",
"add_notify_event",
"(",
"self",
".",
"ihc_id",
",",
"self",
".",
"on_ihc_change",
",",
"True",
")"
] | [
29,
4
] | [
31,
83
] | python | en | ['en', 'en', 'en'] | True |
IHCDevice.should_poll | (self) | No polling needed for IHC devices. | No polling needed for IHC devices. | def should_poll(self) -> bool:
"""No polling needed for IHC devices."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
34,
4
] | [
36,
20
] | python | en | ['en', 'en', 'en'] | True |
IHCDevice.name | (self) | Return the device name. | Return the device name. | def name(self):
"""Return the device name."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
39,
4
] | [
41,
25
] | python | en | ['en', 'en', 'en'] | True |
IHCDevice.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
if not self.info:
return {}
return {
"ihc_id": self.ihc_id,
"ihc_name": self.ihc_name,
"ihc_note": self.ihc_note,
"ihc_position": self.ihc_position,
} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"info",
":",
"return",
"{",
"}",
"return",
"{",
"\"ihc_id\"",
":",
"self",
".",
"ihc_id",
",",
"\"ihc_name\"",
":",
"self",
".",
"ihc_name",
",",
"\"ihc_note\"",
":",
"sel... | [
44,
4
] | [
53,
9
] | python | en | ['en', 'en', 'en'] | True |
IHCDevice.on_ihc_change | (self, ihc_id, value) | Handle IHC resource change.
Derived classes must overwrite this to do device specific stuff.
| Handle IHC resource change. | def on_ihc_change(self, ihc_id, value):
"""Handle IHC resource change.
Derived classes must overwrite this to do device specific stuff.
"""
raise NotImplementedError | [
"def",
"on_ihc_change",
"(",
"self",
",",
"ihc_id",
",",
"value",
")",
":",
"raise",
"NotImplementedError"
] | [
55,
4
] | [
60,
33
] | python | en | ['en', 'xh', 'en'] | True |
fahrenheit_to_celsius | (fahrenheit: float, interval: bool = False) | Convert a temperature in Fahrenheit to Celsius. | Convert a temperature in Fahrenheit to Celsius. | def fahrenheit_to_celsius(fahrenheit: float, interval: bool = False) -> float:
"""Convert a temperature in Fahrenheit to Celsius."""
if interval:
return fahrenheit / 1.8
return (fahrenheit - 32.0) / 1.8 | [
"def",
"fahrenheit_to_celsius",
"(",
"fahrenheit",
":",
"float",
",",
"interval",
":",
"bool",
"=",
"False",
")",
"->",
"float",
":",
"if",
"interval",
":",
"return",
"fahrenheit",
"/",
"1.8",
"return",
"(",
"fahrenheit",
"-",
"32.0",
")",
"/",
"1.8"
] | [
9,
0
] | [
13,
36
] | python | en | ['en', 'la', 'nl'] | False |
celsius_to_fahrenheit | (celsius: float, interval: bool = False) | Convert a temperature in Celsius to Fahrenheit. | Convert a temperature in Celsius to Fahrenheit. | def celsius_to_fahrenheit(celsius: float, interval: bool = False) -> float:
"""Convert a temperature in Celsius to Fahrenheit."""
if interval:
return celsius * 1.8
return celsius * 1.8 + 32.0 | [
"def",
"celsius_to_fahrenheit",
"(",
"celsius",
":",
"float",
",",
"interval",
":",
"bool",
"=",
"False",
")",
"->",
"float",
":",
"if",
"interval",
":",
"return",
"celsius",
"*",
"1.8",
"return",
"celsius",
"*",
"1.8",
"+",
"32.0"
] | [
16,
0
] | [
20,
31
] | python | en | ['en', 'la', 'nl'] | False |
convert | (
temperature: float, from_unit: str, to_unit: str, interval: bool = False
) | Convert a temperature from one unit to another. | Convert a temperature from one unit to another. | def convert(
temperature: float, from_unit: str, to_unit: str, interval: bool = False
) -> float:
"""Convert a temperature from one unit to another."""
if from_unit not in (TEMP_CELSIUS, TEMP_FAHRENHEIT):
raise ValueError(UNIT_NOT_RECOGNIZED_TEMPLATE.format(from_unit, TEMPERATURE))
if to_unit no... | [
"def",
"convert",
"(",
"temperature",
":",
"float",
",",
"from_unit",
":",
"str",
",",
"to_unit",
":",
"str",
",",
"interval",
":",
"bool",
"=",
"False",
")",
"->",
"float",
":",
"if",
"from_unit",
"not",
"in",
"(",
"TEMP_CELSIUS",
",",
"TEMP_FAHRENHEIT"... | [
23,
0
] | [
36,
55
] | python | en | ['en', 'en', 'en'] | True |
test_entity_and_device_attributes | (hass, device_factory) | Test the attributes of the entity are correct. | Test the attributes of the entity are correct. | async def test_entity_and_device_attributes(hass, device_factory):
"""Test the attributes of the entity are correct."""
# Arrange
device = device_factory("Switch_1", [Capability.switch], {Attribute.switch: "on"})
entity_registry = await hass.helpers.entity_registry.async_get_registry()
device_regist... | [
"async",
"def",
"test_entity_and_device_attributes",
"(",
"hass",
",",
"device_factory",
")",
":",
"# Arrange",
"device",
"=",
"device_factory",
"(",
"\"Switch_1\"",
",",
"[",
"Capability",
".",
"switch",
"]",
",",
"{",
"Attribute",
".",
"switch",
":",
"\"on\"",... | [
19,
0
] | [
36,
46
] | python | en | ['en', 'en', 'en'] | True |
test_turn_off | (hass, device_factory) | Test the switch turns of successfully. | Test the switch turns of successfully. | async def test_turn_off(hass, device_factory):
"""Test the switch turns of successfully."""
# Arrange
device = device_factory("Switch_1", [Capability.switch], {Attribute.switch: "on"})
await setup_platform(hass, SWITCH_DOMAIN, devices=[device])
# Act
await hass.services.async_call(
"swit... | [
"async",
"def",
"test_turn_off",
"(",
"hass",
",",
"device_factory",
")",
":",
"# Arrange",
"device",
"=",
"device_factory",
"(",
"\"Switch_1\"",
",",
"[",
"Capability",
".",
"switch",
"]",
",",
"{",
"Attribute",
".",
"switch",
":",
"\"on\"",
"}",
")",
"aw... | [
39,
0
] | [
51,
31
] | python | en | ['en', 'en', 'en'] | True |
test_turn_on | (hass, device_factory) | Test the switch turns of successfully. | Test the switch turns of successfully. | async def test_turn_on(hass, device_factory):
"""Test the switch turns of successfully."""
# Arrange
device = device_factory(
"Switch_1",
[Capability.switch, Capability.power_meter, Capability.energy_meter],
{Attribute.switch: "off", Attribute.power: 355, Attribute.energy: 11.422},
... | [
"async",
"def",
"test_turn_on",
"(",
"hass",
",",
"device_factory",
")",
":",
"# Arrange",
"device",
"=",
"device_factory",
"(",
"\"Switch_1\"",
",",
"[",
"Capability",
".",
"switch",
",",
"Capability",
".",
"power_meter",
",",
"Capability",
".",
"energy_meter",... | [
54,
0
] | [
72,
60
] | python | en | ['en', 'en', 'en'] | True |
test_update_from_signal | (hass, device_factory) | Test the switch updates when receiving a signal. | Test the switch updates when receiving a signal. | async def test_update_from_signal(hass, device_factory):
"""Test the switch updates when receiving a signal."""
# Arrange
device = device_factory("Switch_1", [Capability.switch], {Attribute.switch: "off"})
await setup_platform(hass, SWITCH_DOMAIN, devices=[device])
await device.switch_on(True)
#... | [
"async",
"def",
"test_update_from_signal",
"(",
"hass",
",",
"device_factory",
")",
":",
"# Arrange",
"device",
"=",
"device_factory",
"(",
"\"Switch_1\"",
",",
"[",
"Capability",
".",
"switch",
"]",
",",
"{",
"Attribute",
".",
"switch",
":",
"\"off\"",
"}",
... | [
75,
0
] | [
87,
30
] | python | en | ['en', 'en', 'en'] | True |
test_unload_config_entry | (hass, device_factory) | Test the switch is removed when the config entry is unloaded. | Test the switch is removed when the config entry is unloaded. | async def test_unload_config_entry(hass, device_factory):
"""Test the switch is removed when the config entry is unloaded."""
# Arrange
device = device_factory("Switch 1", [Capability.switch], {Attribute.switch: "on"})
config_entry = await setup_platform(hass, SWITCH_DOMAIN, devices=[device])
# Act
... | [
"async",
"def",
"test_unload_config_entry",
"(",
"hass",
",",
"device_factory",
")",
":",
"# Arrange",
"device",
"=",
"device_factory",
"(",
"\"Switch 1\"",
",",
"[",
"Capability",
".",
"switch",
"]",
",",
"{",
"Attribute",
".",
"switch",
":",
"\"on\"",
"}",
... | [
90,
0
] | [
98,
49
] | python | en | ['en', 'en', 'en'] | True |
ids_tensor | (shape, vocab_size, rng=None) | Creates a random int32 tensor of the shape within the vocab size. | Creates a random int32 tensor of the shape within the vocab size. | def ids_tensor(shape, vocab_size, rng=None):
"""Creates a random int32 tensor of the shape within the vocab size."""
if rng is None:
rng = random.Random()
total_dims = 1
for dim in shape:
total_dims *= dim
values = []
for _ in range(total_dims):
values.append(rng.randin... | [
"def",
"ids_tensor",
"(",
"shape",
",",
"vocab_size",
",",
"rng",
"=",
"None",
")",
":",
"if",
"rng",
"is",
"None",
":",
"rng",
"=",
"random",
".",
"Random",
"(",
")",
"total_dims",
"=",
"1",
"for",
"dim",
"in",
"shape",
":",
"total_dims",
"*=",
"d... | [
37,
0
] | [
52,
17
] | python | en | ['en', 'en', 'en'] | True |
mock_transmission_api | () | Mock an api. | Mock an api. | def mock_transmission_api():
"""Mock an api."""
with patch("transmissionrpc.Client"):
yield | [
"def",
"mock_transmission_api",
"(",
")",
":",
"with",
"patch",
"(",
"\"transmissionrpc.Client\"",
")",
":",
"yield"
] | [
47,
0
] | [
50,
13
] | python | en | ['en', 'su', 'en'] | True |
mock_api_authentication_error | () | Mock an api. | Mock an api. | def mock_api_authentication_error():
"""Mock an api."""
with patch(
"transmissionrpc.Client", side_effect=TransmissionError("401: Unauthorized")
):
yield | [
"def",
"mock_api_authentication_error",
"(",
")",
":",
"with",
"patch",
"(",
"\"transmissionrpc.Client\"",
",",
"side_effect",
"=",
"TransmissionError",
"(",
"\"401: Unauthorized\"",
")",
")",
":",
"yield"
] | [
54,
0
] | [
59,
13
] | python | en | ['en', 'su', 'en'] | True |
mock_api_connection_error | () | Mock an api. | Mock an api. | def mock_api_connection_error():
"""Mock an api."""
with patch(
"transmissionrpc.Client",
side_effect=TransmissionError("111: Connection refused"),
):
yield | [
"def",
"mock_api_connection_error",
"(",
")",
":",
"with",
"patch",
"(",
"\"transmissionrpc.Client\"",
",",
"side_effect",
"=",
"TransmissionError",
"(",
"\"111: Connection refused\"",
")",
",",
")",
":",
"yield"
] | [
63,
0
] | [
69,
13
] | python | en | ['en', 'su', 'en'] | True |
mock_api_unknown_error | () | Mock an api. | Mock an api. | def mock_api_unknown_error():
"""Mock an api."""
with patch("transmissionrpc.Client", side_effect=TransmissionError):
yield | [
"def",
"mock_api_unknown_error",
"(",
")",
":",
"with",
"patch",
"(",
"\"transmissionrpc.Client\"",
",",
"side_effect",
"=",
"TransmissionError",
")",
":",
"yield"
] | [
73,
0
] | [
76,
13
] | python | en | ['en', 'su', 'en'] | True |
transmission_setup_fixture | () | Mock transmission entry setup. | Mock transmission entry setup. | def transmission_setup_fixture():
"""Mock transmission entry setup."""
with patch(
"homeassistant.components.transmission.async_setup_entry", return_value=True
):
yield | [
"def",
"transmission_setup_fixture",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.transmission.async_setup_entry\"",
",",
"return_value",
"=",
"True",
")",
":",
"yield"
] | [
80,
0
] | [
85,
13
] | python | en | ['en', 'da', 'en'] | True |
init_config_flow | (hass) | Init a configuration flow. | Init a configuration flow. | def init_config_flow(hass):
"""Init a configuration flow."""
flow = config_flow.TransmissionFlowHandler()
flow.hass = hass
return flow | [
"def",
"init_config_flow",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"TransmissionFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"return",
"flow"
] | [
88,
0
] | [
92,
15
] | python | en | ['es', 'fr', 'en'] | False |
test_flow_user_config | (hass, api) | Test user config. | Test user config. | async def test_flow_user_config(hass, api):
"""Test user config."""
result = await hass.config_entries.flow.async_init(
transmission.DOMAIN, context={"source": "user"}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "user" | [
"async",
"def",
"test_flow_user_config",
"(",
"hass",
",",
"api",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"transmission",
".",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"\"user\"",
... | [
95,
0
] | [
101,
38
] | python | en | ['en', 'da', 'en'] | True |
test_flow_required_fields | (hass, api) | Test with required fields only. | Test with required fields only. | async def test_flow_required_fields(hass, api):
"""Test with required fields only."""
result = await hass.config_entries.flow.async_init(
transmission.DOMAIN,
context={"source": "user"},
data={CONF_NAME: NAME, CONF_HOST: HOST, CONF_PORT: PORT},
)
assert result["type"] == data_en... | [
"async",
"def",
"test_flow_required_fields",
"(",
"hass",
",",
"api",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"transmission",
".",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"\"user\""... | [
104,
0
] | [
116,
44
] | python | en | ['en', 'en', 'en'] | True |
test_flow_all_provided | (hass, api) | Test with all provided. | Test with all provided. | async def test_flow_all_provided(hass, api):
"""Test with all provided."""
result = await hass.config_entries.flow.async_init(
transmission.DOMAIN, context={"source": "user"}, data=MOCK_ENTRY
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == NAME
... | [
"async",
"def",
"test_flow_all_provided",
"(",
"hass",
",",
"api",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"transmission",
".",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"\"user\"",
... | [
119,
0
] | [
131,
44
] | python | en | ['en', 'en', 'en'] | True |
test_options | (hass) | Test updating options. | Test updating options. | async def test_options(hass):
"""Test updating options."""
entry = MockConfigEntry(
domain=transmission.DOMAIN,
title=CONF_NAME,
data=MOCK_ENTRY,
options={CONF_SCAN_INTERVAL: DEFAULT_SCAN_INTERVAL},
)
flow = init_config_flow(hass)
options_flow = flow.async_get_options... | [
"async",
"def",
"test_options",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"transmission",
".",
"DOMAIN",
",",
"title",
"=",
"CONF_NAME",
",",
"data",
"=",
"MOCK_ENTRY",
",",
"options",
"=",
"{",
"CONF_SCAN_INTERVAL",
":",
... | [
134,
0
] | [
150,
51
] | python | en | ['en', 'en', 'en'] | True |
test_import | (hass, api) | Test import step. | Test import step. | async def test_import(hass, api):
"""Test import step."""
flow = init_config_flow(hass)
# import with minimum fields only
result = await flow.async_step_import(
{
CONF_NAME: DEFAULT_NAME,
CONF_HOST: HOST,
CONF_PORT: DEFAULT_PORT,
CONF_SCAN_INTERVA... | [
"async",
"def",
"test_import",
"(",
"hass",
",",
"api",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"# import with minimum fields only",
"result",
"=",
"await",
"flow",
".",
"async_step_import",
"(",
"{",
"CONF_NAME",
":",
"DEFAULT_NAME",
",",
... | [
153,
0
] | [
195,
62
] | python | de | ['de', 'sd', 'en'] | False |
test_host_already_configured | (hass, api) | Test host is already configured. | Test host is already configured. | async def test_host_already_configured(hass, api):
"""Test host is already configured."""
entry = MockConfigEntry(
domain=transmission.DOMAIN,
data=MOCK_ENTRY,
options={CONF_SCAN_INTERVAL: DEFAULT_SCAN_INTERVAL},
)
entry.add_to_hass(hass)
mock_entry_unique_name = MOCK_ENTRY.... | [
"async",
"def",
"test_host_already_configured",
"(",
"hass",
",",
"api",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"transmission",
".",
"DOMAIN",
",",
"data",
"=",
"MOCK_ENTRY",
",",
"options",
"=",
"{",
"CONF_SCAN_INTERVAL",
":",
"DEFAULT... | [
198,
0
] | [
229,
69
] | python | en | ['en', 'en', 'en'] | True |
test_name_already_configured | (hass, api) | Test name is already configured. | Test name is already configured. | async def test_name_already_configured(hass, api):
"""Test name is already configured."""
entry = MockConfigEntry(
domain=transmission.DOMAIN,
data=MOCK_ENTRY,
options={CONF_SCAN_INTERVAL: DEFAULT_SCAN_INTERVAL},
)
entry.add_to_hass(hass)
mock_entry = MOCK_ENTRY.copy()
m... | [
"async",
"def",
"test_name_already_configured",
"(",
"hass",
",",
"api",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"transmission",
".",
"DOMAIN",
",",
"data",
"=",
"MOCK_ENTRY",
",",
"options",
"=",
"{",
"CONF_SCAN_INTERVAL",
":",
"DEFAULT... | [
232,
0
] | [
248,
57
] | python | en | ['en', 'en', 'en'] | True |
test_error_on_wrong_credentials | (hass, auth_error) | Test with wrong credentials. | Test with wrong credentials. | async def test_error_on_wrong_credentials(hass, auth_error):
"""Test with wrong credentials."""
flow = init_config_flow(hass)
result = await flow.async_step_user(
{
CONF_NAME: NAME,
CONF_HOST: HOST,
CONF_USERNAME: USERNAME,
CONF_PASSWORD: PASSWORD,
... | [
"async",
"def",
"test_error_on_wrong_credentials",
"(",
"hass",
",",
"auth_error",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"result",
"=",
"await",
"flow",
".",
"async_step_user",
"(",
"{",
"CONF_NAME",
":",
"NAME",
",",
"CONF_HOST",
":",
... | [
251,
0
] | [
268,
5
] | python | en | ['en', 'en', 'en'] | True |
test_error_on_connection_failure | (hass, conn_error) | Test when connection to host fails. | Test when connection to host fails. | async def test_error_on_connection_failure(hass, conn_error):
"""Test when connection to host fails."""
flow = init_config_flow(hass)
result = await flow.async_step_user(
{
CONF_NAME: NAME,
CONF_HOST: HOST,
CONF_USERNAME: USERNAME,
CONF_PASSWORD: PASS... | [
"async",
"def",
"test_error_on_connection_failure",
"(",
"hass",
",",
"conn_error",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"result",
"=",
"await",
"flow",
".",
"async_step_user",
"(",
"{",
"CONF_NAME",
":",
"NAME",
",",
"CONF_HOST",
":",
... | [
271,
0
] | [
285,
57
] | python | en | ['en', 'en', 'en'] | True |
test_error_on_unknwon_error | (hass, unknown_error) | Test when connection to host fails. | Test when connection to host fails. | async def test_error_on_unknwon_error(hass, unknown_error):
"""Test when connection to host fails."""
flow = init_config_flow(hass)
result = await flow.async_step_user(
{
CONF_NAME: NAME,
CONF_HOST: HOST,
CONF_USERNAME: USERNAME,
CONF_PASSWORD: PASSWO... | [
"async",
"def",
"test_error_on_unknwon_error",
"(",
"hass",
",",
"unknown_error",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"result",
"=",
"await",
"flow",
".",
"async_step_user",
"(",
"{",
"CONF_NAME",
":",
"NAME",
",",
"CONF_HOST",
":",
... | [
288,
0
] | [
302,
57
] | python | en | ['en', 'en', 'en'] | True |
RetriBertPreTrainedModel._init_weights | (self, module) | Initialize the weights | Initialize the weights | def _init_weights(self, module):
""" Initialize the weights """
if isinstance(module, nn.Linear):
module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
if module.bias is not None:
module.bias.data.zero_()
elif isinstance(module, nn.Embedd... | [
"def",
"_init_weights",
"(",
"self",
",",
"module",
")",
":",
"if",
"isinstance",
"(",
"module",
",",
"nn",
".",
"Linear",
")",
":",
"module",
".",
"weight",
".",
"data",
".",
"normal_",
"(",
"mean",
"=",
"0.0",
",",
"std",
"=",
"self",
".",
"confi... | [
51,
4
] | [
63,
41
] | python | en | ['en', 'en', 'en'] | True |
VmSchedulingBusinessEngine.configs | (self) | dict: Current configuration. | dict: Current configuration. | def configs(self) -> dict:
"""dict: Current configuration."""
return self._config | [
"def",
"configs",
"(",
"self",
")",
"->",
"dict",
":",
"return",
"self",
".",
"_config"
] | [
94,
4
] | [
96,
27
] | python | en | ['en', 'la', 'en'] | True |
VmSchedulingBusinessEngine.frame | (self) | FrameBase: Current frame. | FrameBase: Current frame. | def frame(self) -> FrameBase:
"""FrameBase: Current frame."""
return self._frame | [
"def",
"frame",
"(",
"self",
")",
"->",
"FrameBase",
":",
"return",
"self",
".",
"_frame"
] | [
99,
4
] | [
101,
26
] | python | en | ['en', 'no', 'en'] | True |
VmSchedulingBusinessEngine.snapshots | (self) | SnapshotList: Current snapshot list. | SnapshotList: Current snapshot list. | def snapshots(self) -> SnapshotList:
"""SnapshotList: Current snapshot list."""
return self._snapshots | [
"def",
"snapshots",
"(",
"self",
")",
"->",
"SnapshotList",
":",
"return",
"self",
".",
"_snapshots"
] | [
104,
4
] | [
106,
30
] | python | en | ['en', 'de', 'en'] | True |
VmSchedulingBusinessEngine._load_configs | (self) | Load configurations. | Load configurations. | def _load_configs(self):
"""Load configurations."""
# Update self._config_path with current file path.
self.update_config_root_path(__file__)
with open(os.path.join(self._config_path, "config.yml")) as fp:
self._config = convert_dottable(safe_load(fp))
self._delay_du... | [
"def",
"_load_configs",
"(",
"self",
")",
":",
"# Update self._config_path with current file path.",
"self",
".",
"update_config_root_path",
"(",
"__file__",
")",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_config_path",
",",
"\"config... | [
108,
4
] | [
172,
84
] | python | en | ['en', 'ca', 'en'] | False |
VmSchedulingBusinessEngine._init_data | (self) | If the file does not exist, then trigger the short data pipeline to download the processed data. | If the file does not exist, then trigger the short data pipeline to download the processed data. | def _init_data(self):
"""If the file does not exist, then trigger the short data pipeline to download the processed data."""
vm_table_data_path = self._config.VM_TABLE
if vm_table_data_path.startswith("~"):
vm_table_data_path = os.path.expanduser(vm_table_data_path)
cpu_read... | [
"def",
"_init_data",
"(",
"self",
")",
":",
"vm_table_data_path",
"=",
"self",
".",
"_config",
".",
"VM_TABLE",
"if",
"vm_table_data_path",
".",
"startswith",
"(",
"\"~\"",
")",
":",
"vm_table_data_path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"vm_t... | [
190,
4
] | [
206,
62
] | python | en | ['en', 'en', 'en'] | True |
VmSchedulingBusinessEngine._init_structure | (self) | Initialize the whole pm structure. | Initialize the whole pm structure. | def _init_structure(self):
"""Initialize the whole pm structure."""
# TODO: Improve the scalability. Like the use of multiple PM sets.
self._regions = self._frame.regions
self._zones = self._frame.zones
self._data_centers = self._frame.data_centers
self._clusters = self._... | [
"def",
"_init_structure",
"(",
"self",
")",
":",
"# TODO: Improve the scalability. Like the use of multiple PM sets.",
"self",
".",
"_regions",
"=",
"self",
".",
"_frame",
".",
"regions",
"self",
".",
"_zones",
"=",
"self",
".",
"_frame",
".",
"zones",
"self",
"."... | [
220,
4
] | [
253,
28
] | python | en | ['en', 'en', 'en'] | True |
VmSchedulingBusinessEngine._init_regions | (self) | Initialize the regions based on the config setting. The regions id starts from 0. | Initialize the regions based on the config setting. The regions id starts from 0. | def _init_regions(self):
"""Initialize the regions based on the config setting. The regions id starts from 0."""
for region_list in self._find_item("region", self._config.architecture):
for region_dict in region_list:
# Initialize zones.
start_zone_id = self._... | [
"def",
"_init_regions",
"(",
"self",
")",
":",
"for",
"region_list",
"in",
"self",
".",
"_find_item",
"(",
"\"region\"",
",",
"self",
".",
"_config",
".",
"architecture",
")",
":",
"for",
"region_dict",
"in",
"region_list",
":",
"# Initialize zones.",
"start_z... | [
255,
4
] | [
273,
36
] | python | en | ['en', 'en', 'en'] | True |
VmSchedulingBusinessEngine._init_zones | (self, zone_list: list) | Initialize the zones based on the config setting. The zone id starts from 0. | Initialize the zones based on the config setting. The zone id starts from 0. | def _init_zones(self, zone_list: list):
"""Initialize the zones based on the config setting. The zone id starts from 0."""
start_zone_id = self._zone_id
for zone_dict in zone_list:
# Initialize data centers.
start_data_center_id = self._init_data_centers(
... | [
"def",
"_init_zones",
"(",
"self",
",",
"zone_list",
":",
"list",
")",
":",
"start_zone_id",
"=",
"self",
".",
"_zone_id",
"for",
"zone_dict",
"in",
"zone_list",
":",
"# Initialize data centers.",
"start_data_center_id",
"=",
"self",
".",
"_init_data_centers",
"("... | [
275,
4
] | [
297,
28
] | python | en | ['en', 'en', 'en'] | True |
VmSchedulingBusinessEngine._init_data_centers | (self, data_center_list: list) | Initialize the data_centers based on the config setting. The data_center id starts from 0. | Initialize the data_centers based on the config setting. The data_center id starts from 0. | def _init_data_centers(self, data_center_list: list):
"""Initialize the data_centers based on the config setting. The data_center id starts from 0."""
start_data_center_id = self._data_center_id
for data_center_dict in data_center_list:
# Initialize clusters.
start_cluste... | [
"def",
"_init_data_centers",
"(",
"self",
",",
"data_center_list",
":",
"list",
")",
":",
"start_data_center_id",
"=",
"self",
".",
"_data_center_id",
"for",
"data_center_dict",
"in",
"data_center_list",
":",
"# Initialize clusters.",
"start_cluster_id",
"=",
"self",
... | [
299,
4
] | [
321,
35
] | python | en | ['en', 'en', 'en'] | True |
VmSchedulingBusinessEngine._init_clusters | (self, cluster_list: list) | Initialize the clusters based on the config setting. The cluster id starts from 0. | Initialize the clusters based on the config setting. The cluster id starts from 0. | def _init_clusters(self, cluster_list: list):
"""Initialize the clusters based on the config setting. The cluster id starts from 0."""
start_cluster_id = self._cluster_id
for cluster in cluster_list:
cluster_type = cluster['type']
cluster_amount = cluster['cluster_amount'... | [
"def",
"_init_clusters",
"(",
"self",
",",
"cluster_list",
":",
"list",
")",
":",
"start_cluster_id",
"=",
"self",
".",
"_cluster_id",
"for",
"cluster",
"in",
"cluster_list",
":",
"cluster_type",
"=",
"cluster",
"[",
"'type'",
"]",
"cluster_amount",
"=",
"clus... | [
323,
4
] | [
351,
31
] | python | en | ['en', 'en', 'en'] | True |
VmSchedulingBusinessEngine._init_racks | (self, rack_amount_dict: dict) | Initialize the racks based on the config setting. The rack id starts from 0. | Initialize the racks based on the config setting. The rack id starts from 0. | def _init_racks(self, rack_amount_dict: dict):
"""Initialize the racks based on the config setting. The rack id starts from 0."""
start_rack_id = self._rack_id
for rack_type, rack_amount in rack_amount_dict.items():
while rack_amount > 0:
# Initialize pms.
... | [
"def",
"_init_racks",
"(",
"self",
",",
"rack_amount_dict",
":",
"dict",
")",
":",
"start_rack_id",
"=",
"self",
".",
"_rack_id",
"for",
"rack_type",
",",
"rack_amount",
"in",
"rack_amount_dict",
".",
"items",
"(",
")",
":",
"while",
"rack_amount",
">",
"0",... | [
353,
4
] | [
377,
28
] | python | en | ['en', 'en', 'en'] | True |
VmSchedulingBusinessEngine._init_pms | (self, pm_dict: dict) | Initialize the pms based on the config setting. The pm id starts from 0. | Initialize the pms based on the config setting. The pm id starts from 0. | def _init_pms(self, pm_dict: dict):
"""Initialize the pms based on the config setting. The pm id starts from 0."""
start_pm_id = self._pm_id
for pm_type, pm_amount in pm_dict.items():
while pm_amount > 0:
pm = self._machines[self._pm_id]
pm.set_init_st... | [
"def",
"_init_pms",
"(",
"self",
",",
"pm_dict",
":",
"dict",
")",
":",
"start_pm_id",
"=",
"self",
".",
"_pm_id",
"for",
"pm_type",
",",
"pm_amount",
"in",
"pm_dict",
".",
"items",
"(",
")",
":",
"while",
"pm_amount",
">",
"0",
":",
"pm",
"=",
"self... | [
379,
4
] | [
405,
26
] | python | en | ['en', 'en', 'en'] | True |
VmSchedulingBusinessEngine.reset | (self) | Reset internal states for episode. | Reset internal states for episode. | def reset(self):
"""Reset internal states for episode."""
self._init_metrics()
self._frame.reset()
self._snapshots.reset()
for pm in self._machines:
pm.reset()
for rack in self._racks:
rack.reset()
for cluster in self._clusters:
... | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"_init_metrics",
"(",
")",
"self",
".",
"_frame",
".",
"reset",
"(",
")",
"self",
".",
"_snapshots",
".",
"reset",
"(",
")",
"for",
"pm",
"in",
"self",
".",
"_machines",
":",
"pm",
".",
"reset",
... | [
407,
4
] | [
438,
32
] | python | en | ['en', 'en', 'en'] | True |
VmSchedulingBusinessEngine.step | (self, tick: int) | Push business to next step.
Args:
tick (int): Current tick to process.
| Push business to next step. | def step(self, tick: int):
"""Push business to next step.
Args:
tick (int): Current tick to process.
"""
self._tick = tick
# All vm's cpu utilization at current tick.
cur_tick_cpu_utilization = self._cpu_reader.items(tick=tick)
# Process finished VMs... | [
"def",
"step",
"(",
"self",
",",
"tick",
":",
"int",
")",
":",
"self",
".",
"_tick",
"=",
"tick",
"# All vm's cpu utilization at current tick.",
"cur_tick_cpu_utilization",
"=",
"self",
".",
"_cpu_reader",
".",
"items",
"(",
"tick",
"=",
"tick",
")",
"# Proces... | [
452,
4
] | [
499,
40
] | python | en | ['en', 'en', 'en'] | True |
VmSchedulingBusinessEngine.get_event_payload_detail | (self) | dict: Event payload details of current scenario. | dict: Event payload details of current scenario. | def get_event_payload_detail(self) -> dict:
"""dict: Event payload details of current scenario."""
return {
Events.REQUEST.name: VmRequestPayload.summary_key,
MaroEvents.PENDING_DECISION.name: DecisionPayload.summary_key
} | [
"def",
"get_event_payload_detail",
"(",
"self",
")",
"->",
"dict",
":",
"return",
"{",
"Events",
".",
"REQUEST",
".",
"name",
":",
"VmRequestPayload",
".",
"summary_key",
",",
"MaroEvents",
".",
"PENDING_DECISION",
".",
"name",
":",
"DecisionPayload",
".",
"su... | [
534,
4
] | [
539,
9
] | python | en | ['en', 'en', 'en'] | True |
VmSchedulingBusinessEngine.get_agent_idx_list | (self) | Get a list of agent index. | Get a list of agent index. | def get_agent_idx_list(self) -> List[int]:
"""Get a list of agent index."""
pass | [
"def",
"get_agent_idx_list",
"(",
"self",
")",
"->",
"List",
"[",
"int",
"]",
":",
"pass"
] | [
541,
4
] | [
543,
12
] | python | en | ['en', 'en', 'en'] | True |
VmSchedulingBusinessEngine.get_node_mapping | (self) | dict: Node mapping. | dict: Node mapping. | def get_node_mapping(self) -> dict:
"""dict: Node mapping."""
node_mapping = {}
return node_mapping | [
"def",
"get_node_mapping",
"(",
"self",
")",
"->",
"dict",
":",
"node_mapping",
"=",
"{",
"}",
"return",
"node_mapping"
] | [
545,
4
] | [
549,
27
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.