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_cleanup_device_several_triggers | (hass, device_reg, entity_reg, mqtt_mock) | Test removal from device registry when the last trigger is removed. | Test removal from device registry when the last trigger is removed. | async def test_cleanup_device_several_triggers(hass, device_reg, entity_reg, mqtt_mock):
"""Test removal from device registry when the last trigger is removed."""
config1 = {
"automation_type": "trigger",
"topic": "test-topic",
"type": "foo",
"subtype": "bar",
"device": {... | [
"async",
"def",
"test_cleanup_device_several_triggers",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
",",
"mqtt_mock",
")",
":",
"config1",
"=",
"{",
"\"automation_type\"",
":",
"\"trigger\"",
",",
"\"topic\"",
":",
"\"test-topic\"",
",",
"\"type\"",
":",
"\... | [
923,
0
] | [
973,
31
] | python | en | ['en', 'en', 'en'] | True |
test_cleanup_device_with_entity1 | (hass, device_reg, entity_reg, mqtt_mock) | Test removal from device registry for device with entity.
Trigger removed first, then entity.
| Test removal from device registry for device with entity. | async def test_cleanup_device_with_entity1(hass, device_reg, entity_reg, mqtt_mock):
"""Test removal from device registry for device with entity.
Trigger removed first, then entity.
"""
config1 = {
"automation_type": "trigger",
"topic": "test-topic",
"type": "foo",
"subt... | [
"async",
"def",
"test_cleanup_device_with_entity1",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
",",
"mqtt_mock",
")",
":",
"config1",
"=",
"{",
"\"automation_type\"",
":",
"\"trigger\"",
",",
"\"topic\"",
":",
"\"test-topic\"",
",",
"\"type\"",
":",
"\"foo... | [
976,
0
] | [
1025,
31
] | python | en | ['en', 'en', 'en'] | True |
test_cleanup_device_with_entity2 | (hass, device_reg, entity_reg, mqtt_mock) | Test removal from device registry for device with entity.
Entity removed first, then trigger.
| Test removal from device registry for device with entity. | async def test_cleanup_device_with_entity2(hass, device_reg, entity_reg, mqtt_mock):
"""Test removal from device registry for device with entity.
Entity removed first, then trigger.
"""
config1 = {
"automation_type": "trigger",
"topic": "test-topic",
"type": "foo",
"subt... | [
"async",
"def",
"test_cleanup_device_with_entity2",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
",",
"mqtt_mock",
")",
":",
"config1",
"=",
"{",
"\"automation_type\"",
":",
"\"trigger\"",
",",
"\"topic\"",
":",
"\"test-topic\"",
",",
"\"type\"",
":",
"\"foo... | [
1028,
0
] | [
1077,
31
] | python | en | ['en', 'en', 'en'] | True |
test_trigger_debug_info | (hass, mqtt_mock) | Test debug_info.
This is a test helper for MQTT debug_info.
| Test debug_info. | async def test_trigger_debug_info(hass, mqtt_mock):
"""Test debug_info.
This is a test helper for MQTT debug_info.
"""
registry = await hass.helpers.device_registry.async_get_registry()
config = {
"platform": "mqtt",
"automation_type": "trigger",
"topic": "test-topic",
... | [
"async",
"def",
"test_trigger_debug_info",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"device_registry",
".",
"async_get_registry",
"(",
")",
"config",
"=",
"{",
"\"platform\"",
":",
"\"mqtt\"",
",",
"\"auto... | [
1080,
0
] | [
1115,
80
] | python | ceb | ['fr', 'ceb', 'pt'] | False |
get_scanner | (hass, config) | Return a router scanner instance. | Return a router scanner instance. | def get_scanner(hass, config):
"""Return a router scanner instance."""
scanner = EEBrightBoxScanner(config[DOMAIN])
return scanner if scanner.check_config() else None | [
"def",
"get_scanner",
"(",
"hass",
",",
"config",
")",
":",
"scanner",
"=",
"EEBrightBoxScanner",
"(",
"config",
"[",
"DOMAIN",
"]",
")",
"return",
"scanner",
"if",
"scanner",
".",
"check_config",
"(",
")",
"else",
"None"
] | [
32,
0
] | [
36,
54
] | python | en | ['en', 'en', 'en'] | True |
EEBrightBoxScanner.__init__ | (self, config) | Initialise the scanner. | Initialise the scanner. | def __init__(self, config):
"""Initialise the scanner."""
self.config = config
self.devices = {} | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"config",
"=",
"config",
"self",
".",
"devices",
"=",
"{",
"}"
] | [
42,
4
] | [
45,
25
] | python | en | ['en', 'en', 'en'] | True |
EEBrightBoxScanner.check_config | (self) | Check if provided configuration and credentials are correct. | Check if provided configuration and credentials are correct. | def check_config(self):
"""Check if provided configuration and credentials are correct."""
try:
with EEBrightBox(self.config) as ee_brightbox:
return bool(ee_brightbox.get_devices())
except EEBrightBoxException:
_LOGGER.exception("Failed to connect to the ... | [
"def",
"check_config",
"(",
"self",
")",
":",
"try",
":",
"with",
"EEBrightBox",
"(",
"self",
".",
"config",
")",
"as",
"ee_brightbox",
":",
"return",
"bool",
"(",
"ee_brightbox",
".",
"get_devices",
"(",
")",
")",
"except",
"EEBrightBoxException",
":",
"_... | [
47,
4
] | [
54,
24
] | python | en | ['en', 'en', 'en'] | True |
EEBrightBoxScanner.scan_devices | (self) | Scan for devices. | Scan for devices. | def scan_devices(self):
"""Scan for devices."""
with EEBrightBox(self.config) as ee_brightbox:
self.devices = {d["mac"]: d for d in ee_brightbox.get_devices()}
macs = [d["mac"] for d in self.devices.values() if d["activity_ip"]]
_LOGGER.debug("Scan devices %s", macs)
... | [
"def",
"scan_devices",
"(",
"self",
")",
":",
"with",
"EEBrightBox",
"(",
"self",
".",
"config",
")",
"as",
"ee_brightbox",
":",
"self",
".",
"devices",
"=",
"{",
"d",
"[",
"\"mac\"",
"]",
":",
"d",
"for",
"d",
"in",
"ee_brightbox",
".",
"get_devices",... | [
56,
4
] | [
65,
19
] | python | en | ['no', 'en', 'en'] | True |
EEBrightBoxScanner.get_device_name | (self, device) | Get the name of a device from hostname. | Get the name of a device from hostname. | def get_device_name(self, device):
"""Get the name of a device from hostname."""
if device in self.devices:
return self.devices[device]["hostname"] or None
return None | [
"def",
"get_device_name",
"(",
"self",
",",
"device",
")",
":",
"if",
"device",
"in",
"self",
".",
"devices",
":",
"return",
"self",
".",
"devices",
"[",
"device",
"]",
"[",
"\"hostname\"",
"]",
"or",
"None",
"return",
"None"
] | [
67,
4
] | [
72,
19
] | python | en | ['en', 'en', 'en'] | True |
EEBrightBoxScanner.get_extra_attributes | (self, device) |
Get the extra attributes of a device.
Extra attributes include:
- ip
- mac
- port - ethX or wifiX
- last_active
|
Get the extra attributes of a device. | def get_extra_attributes(self, device):
"""
Get the extra attributes of a device.
Extra attributes include:
- ip
- mac
- port - ethX or wifiX
- last_active
"""
port_map = {
"wl1": "wifi5Ghz",
"wl0": "wifi2.4Ghz",
... | [
"def",
"get_extra_attributes",
"(",
"self",
",",
"device",
")",
":",
"port_map",
"=",
"{",
"\"wl1\"",
":",
"\"wifi5Ghz\"",
",",
"\"wl0\"",
":",
"\"wifi2.4Ghz\"",
",",
"\"eth0\"",
":",
"\"eth0\"",
",",
"\"eth1\"",
":",
"\"eth1\"",
",",
"\"eth2\"",
":",
"\"eth... | [
74,
4
] | [
101,
17
] | python | en | ['en', 'error', 'th'] | False |
async_setup_platform | (
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
) | Create a DHW controller. | Create a DHW controller. | async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
) -> None:
"""Create a DHW controller."""
if discovery_info is None:
return
broker = hass.data[DOMAIN]["broker"]
_LOGGER.debug(
"Adding: DhwController (%s), id=%s",
... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
"->",
"None",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"broker",... | [
26,
0
] | [
42,
60
] | python | en | ['en', 'en', 'en'] | True |
EvoDHW.__init__ | (self, evo_broker, evo_device) | Initialize an evohome DHW controller. | Initialize an evohome DHW controller. | def __init__(self, evo_broker, evo_device) -> None:
"""Initialize an evohome DHW controller."""
super().__init__(evo_broker, evo_device)
self._unique_id = evo_device.dhwId
self._name = "DHW controller"
self._icon = "mdi:thermometer-lines"
self._precision = PRECISION_TEN... | [
"def",
"__init__",
"(",
"self",
",",
"evo_broker",
",",
"evo_device",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"evo_broker",
",",
"evo_device",
")",
"self",
".",
"_unique_id",
"=",
"evo_device",
".",
"dhwId",
"self",
".",
"_name",... | [
48,
4
] | [
57,
77
] | python | en | ['en', 'en', 'it'] | True |
EvoDHW.state | (self) | Return the current state. | Return the current state. | def state(self):
"""Return the current state."""
return EVO_STATE_TO_HA[self._evo_device.stateStatus["state"]] | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"EVO_STATE_TO_HA",
"[",
"self",
".",
"_evo_device",
".",
"stateStatus",
"[",
"\"state\"",
"]",
"]"
] | [
60,
4
] | [
62,
69
] | python | en | ['en', 'en', 'en'] | True |
EvoDHW.current_operation | (self) | Return the current operating mode (Auto, On, or Off). | Return the current operating mode (Auto, On, or Off). | def current_operation(self) -> str:
"""Return the current operating mode (Auto, On, or Off)."""
if self._evo_device.stateStatus["mode"] == EVO_FOLLOW:
return STATE_AUTO
return EVO_STATE_TO_HA[self._evo_device.stateStatus["state"]] | [
"def",
"current_operation",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"_evo_device",
".",
"stateStatus",
"[",
"\"mode\"",
"]",
"==",
"EVO_FOLLOW",
":",
"return",
"STATE_AUTO",
"return",
"EVO_STATE_TO_HA",
"[",
"self",
".",
"_evo_device",
".",
"s... | [
65,
4
] | [
69,
69
] | python | en | ['en', 'en', 'en'] | True |
EvoDHW.operation_list | (self) | Return the list of available operations. | Return the list of available operations. | def operation_list(self) -> List[str]:
"""Return the list of available operations."""
return list(HA_STATE_TO_EVO) | [
"def",
"operation_list",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"list",
"(",
"HA_STATE_TO_EVO",
")"
] | [
72,
4
] | [
74,
36
] | python | en | ['en', 'en', 'en'] | True |
EvoDHW.is_away_mode_on | (self) | Return True if away mode is on. | Return True if away mode is on. | def is_away_mode_on(self):
"""Return True if away mode is on."""
is_off = EVO_STATE_TO_HA[self._evo_device.stateStatus["state"]] == STATE_OFF
is_permanent = self._evo_device.stateStatus["mode"] == EVO_PERMOVER
return is_off and is_permanent | [
"def",
"is_away_mode_on",
"(",
"self",
")",
":",
"is_off",
"=",
"EVO_STATE_TO_HA",
"[",
"self",
".",
"_evo_device",
".",
"stateStatus",
"[",
"\"state\"",
"]",
"]",
"==",
"STATE_OFF",
"is_permanent",
"=",
"self",
".",
"_evo_device",
".",
"stateStatus",
"[",
"... | [
77,
4
] | [
81,
38
] | python | en | ['en', 'fy', 'en'] | True |
EvoDHW.async_set_operation_mode | (self, operation_mode: str) | Set new operation mode for a DHW controller.
Except for Auto, the mode is only until the next SetPoint.
| Set new operation mode for a DHW controller. | async def async_set_operation_mode(self, operation_mode: str) -> None:
"""Set new operation mode for a DHW controller.
Except for Auto, the mode is only until the next SetPoint.
"""
if operation_mode == STATE_AUTO:
await self._evo_broker.call_client_api(self._evo_device.set_... | [
"async",
"def",
"async_set_operation_mode",
"(",
"self",
",",
"operation_mode",
":",
"str",
")",
"->",
"None",
":",
"if",
"operation_mode",
"==",
"STATE_AUTO",
":",
"await",
"self",
".",
"_evo_broker",
".",
"call_client_api",
"(",
"self",
".",
"_evo_device",
"... | [
83,
4
] | [
102,
17
] | python | en | ['en', 'en', 'en'] | True |
EvoDHW.async_turn_away_mode_on | (self) | Turn away mode on. | Turn away mode on. | async def async_turn_away_mode_on(self):
"""Turn away mode on."""
await self._evo_broker.call_client_api(self._evo_device.set_dhw_off()) | [
"async",
"def",
"async_turn_away_mode_on",
"(",
"self",
")",
":",
"await",
"self",
".",
"_evo_broker",
".",
"call_client_api",
"(",
"self",
".",
"_evo_device",
".",
"set_dhw_off",
"(",
")",
")"
] | [
104,
4
] | [
106,
78
] | python | en | ['en', 'yo', 'en'] | True |
EvoDHW.async_turn_away_mode_off | (self) | Turn away mode off. | Turn away mode off. | async def async_turn_away_mode_off(self):
"""Turn away mode off."""
await self._evo_broker.call_client_api(self._evo_device.set_dhw_auto()) | [
"async",
"def",
"async_turn_away_mode_off",
"(",
"self",
")",
":",
"await",
"self",
".",
"_evo_broker",
".",
"call_client_api",
"(",
"self",
".",
"_evo_device",
".",
"set_dhw_auto",
"(",
")",
")"
] | [
108,
4
] | [
110,
79
] | python | en | ['en', 'yo', 'en'] | True |
EvoDHW.async_update | (self) | Get the latest state data for a DHW controller. | Get the latest state data for a DHW controller. | async def async_update(self) -> None:
"""Get the latest state data for a DHW controller."""
await super().async_update()
for attr in STATE_ATTRS_DHW:
self._device_state_attrs[attr] = getattr(self._evo_device, attr) | [
"async",
"def",
"async_update",
"(",
"self",
")",
"->",
"None",
":",
"await",
"super",
"(",
")",
".",
"async_update",
"(",
")",
"for",
"attr",
"in",
"STATE_ATTRS_DHW",
":",
"self",
".",
"_device_state_attrs",
"[",
"attr",
"]",
"=",
"getattr",
"(",
"self"... | [
112,
4
] | [
117,
76
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry, async_add_entities) | Configure a dispatcher connection based on a config entry. | Configure a dispatcher connection based on a config entry. | async def async_setup_entry(hass, entry, async_add_entities):
"""Configure a dispatcher connection based on a config entry."""
@callback
def _receive_data(device, location, location_name):
"""Receive set location."""
if device in hass.data[LT_DOMAIN]["devices"]:
return
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
")",
":",
"@",
"callback",
"def",
"_receive_data",
"(",
"device",
",",
"location",
",",
"location_name",
")",
":",
"\"\"\"Receive set location.\"\"\"",
"if",
"device",
"in",... | [
9,
0
] | [
26,
15
] | python | en | ['en', 'en', 'en'] | True |
LocativeEntity.__init__ | (self, device, location, location_name) | Set up Locative entity. | Set up Locative entity. | def __init__(self, device, location, location_name):
"""Set up Locative entity."""
self._name = device
self._location = location
self._location_name = location_name
self._unsub_dispatcher = None | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"location",
",",
"location_name",
")",
":",
"self",
".",
"_name",
"=",
"device",
"self",
".",
"_location",
"=",
"location",
"self",
".",
"_location_name",
"=",
"location_name",
"self",
".",
"_unsub_dispatch... | [
32,
4
] | [
37,
37
] | python | en | ['en', 'mg', 'en'] | True |
LocativeEntity.latitude | (self) | Return latitude value of the device. | Return latitude value of the device. | def latitude(self):
"""Return latitude value of the device."""
return self._location[0] | [
"def",
"latitude",
"(",
"self",
")",
":",
"return",
"self",
".",
"_location",
"[",
"0",
"]"
] | [
40,
4
] | [
42,
32
] | python | en | ['en', 'en', 'en'] | True |
LocativeEntity.longitude | (self) | Return longitude value of the device. | Return longitude value of the device. | def longitude(self):
"""Return longitude value of the device."""
return self._location[1] | [
"def",
"longitude",
"(",
"self",
")",
":",
"return",
"self",
".",
"_location",
"[",
"1",
"]"
] | [
45,
4
] | [
47,
32
] | python | en | ['en', 'zu', 'en'] | True |
LocativeEntity.location_name | (self) | Return a location name for the current location of the device. | Return a location name for the current location of the device. | def location_name(self):
"""Return a location name for the current location of the device."""
return self._location_name | [
"def",
"location_name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_location_name"
] | [
50,
4
] | [
52,
34
] | python | en | ['en', 'en', 'en'] | True |
LocativeEntity.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
55,
4
] | [
57,
25
] | python | en | ['en', 'en', 'en'] | True |
LocativeEntity.source_type | (self) | Return the source type, eg gps or router, of the device. | Return the source type, eg gps or router, of the device. | def source_type(self):
"""Return the source type, eg gps or router, of the device."""
return SOURCE_TYPE_GPS | [
"def",
"source_type",
"(",
"self",
")",
":",
"return",
"SOURCE_TYPE_GPS"
] | [
60,
4
] | [
62,
30
] | python | en | ['en', 'en', 'en'] | True |
LocativeEntity.async_added_to_hass | (self) | Register state update callback. | Register state update callback. | async def async_added_to_hass(self):
"""Register state update callback."""
self._unsub_dispatcher = async_dispatcher_connect(
self.hass, TRACKER_UPDATE, self._async_receive_data
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_unsub_dispatcher",
"=",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"TRACKER_UPDATE",
",",
"self",
".",
"_async_receive_data",
")"
] | [
64,
4
] | [
68,
9
] | python | en | ['en', 'co', 'en'] | True |
LocativeEntity.async_will_remove_from_hass | (self) | Clean up after entity before removal. | Clean up after entity before removal. | async def async_will_remove_from_hass(self):
"""Clean up after entity before removal."""
self._unsub_dispatcher() | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"self",
".",
"_unsub_dispatcher",
"(",
")"
] | [
70,
4
] | [
72,
32
] | python | en | ['en', 'en', 'en'] | True |
LocativeEntity._async_receive_data | (self, device, location, location_name) | Update device data. | Update device data. | def _async_receive_data(self, device, location, location_name):
"""Update device data."""
if device != self._name:
return
self._location_name = location_name
self._location = location
self.async_write_ha_state() | [
"def",
"_async_receive_data",
"(",
"self",
",",
"device",
",",
"location",
",",
"location_name",
")",
":",
"if",
"device",
"!=",
"self",
".",
"_name",
":",
"return",
"self",
".",
"_location_name",
"=",
"location_name",
"self",
".",
"_location",
"=",
"locatio... | [
75,
4
] | [
81,
35
] | python | co | ['fr', 'co', 'en'] | False |
tf_top_k_top_p_filtering | (logits, top_k=0, top_p=1.0, filter_value=-float("Inf"), min_tokens_to_keep=1) |
Filter a distribution of logits using top-k and/or nucleus (top-p) filtering
Args:
logits: logits distribution shape (batch size, vocabulary size)
if top_k > 0: keep only top k tokens with highest probability (top-k filtering).
if top_p < 1.0: keep the top tokens with cumulative probab... |
Filter a distribution of logits using top-k and/or nucleus (top-p) filtering | def tf_top_k_top_p_filtering(logits, top_k=0, top_p=1.0, filter_value=-float("Inf"), min_tokens_to_keep=1):
"""
Filter a distribution of logits using top-k and/or nucleus (top-p) filtering
Args:
logits: logits distribution shape (batch size, vocabulary size)
if top_k > 0: keep only top k to... | [
"def",
"tf_top_k_top_p_filtering",
"(",
"logits",
",",
"top_k",
"=",
"0",
",",
"top_p",
"=",
"1.0",
",",
"filter_value",
"=",
"-",
"float",
"(",
"\"Inf\"",
")",
",",
"min_tokens_to_keep",
"=",
"1",
")",
":",
"logits_shape",
"=",
"shape_list",
"(",
"logits"... | [
1009,
0
] | [
1059,
17
] | python | en | ['en', 'error', 'th'] | False |
sample_without_replacement | (logits, num_samples) |
categorical sampling without replacement is currently not implemented the gumbel-max trick will do for now see
https://github.com/tensorflow/tensorflow/issues/9260 for more info
|
categorical sampling without replacement is currently not implemented the gumbel-max trick will do for now see
https://github.com/tensorflow/tensorflow/issues/9260 for more info
| def sample_without_replacement(logits, num_samples):
"""
categorical sampling without replacement is currently not implemented the gumbel-max trick will do for now see
https://github.com/tensorflow/tensorflow/issues/9260 for more info
"""
z = -tf.math.log(tf.random.uniform(shape_list(logits), 0, 1))... | [
"def",
"sample_without_replacement",
"(",
"logits",
",",
"num_samples",
")",
":",
"z",
"=",
"-",
"tf",
".",
"math",
".",
"log",
"(",
"tf",
".",
"random",
".",
"uniform",
"(",
"shape_list",
"(",
"logits",
")",
",",
"0",
",",
"1",
")",
")",
"_",
",",... | [
1078,
0
] | [
1085,
18
] | python | en | ['en', 'error', 'th'] | False |
shape_list | (x) | Deal with dynamic shape in tensorflow cleanly. | Deal with dynamic shape in tensorflow cleanly. | def shape_list(x):
"""Deal with dynamic shape in tensorflow cleanly."""
static = x.shape.as_list()
dynamic = tf.shape(x)
return [dynamic[i] if s is None else s for i, s in enumerate(static)] | [
"def",
"shape_list",
"(",
"x",
")",
":",
"static",
"=",
"x",
".",
"shape",
".",
"as_list",
"(",
")",
"dynamic",
"=",
"tf",
".",
"shape",
"(",
"x",
")",
"return",
"[",
"dynamic",
"[",
"i",
"]",
"if",
"s",
"is",
"None",
"else",
"s",
"for",
"i",
... | [
1088,
0
] | [
1092,
73
] | python | en | ['en', 'en', 'en'] | True |
TFGenerationMixin.prepare_inputs_for_generation | (self, inputs, **kwargs) |
Implement in subclasses of :class:`~transformers.TFPreTrainedModel` for custom behavior to prepare inputs in
the generate method.
|
Implement in subclasses of :class:`~transformers.TFPreTrainedModel` for custom behavior to prepare inputs in
the generate method.
| def prepare_inputs_for_generation(self, inputs, **kwargs):
"""
Implement in subclasses of :class:`~transformers.TFPreTrainedModel` for custom behavior to prepare inputs in
the generate method.
"""
return {"input_ids": inputs} | [
"def",
"prepare_inputs_for_generation",
"(",
"self",
",",
"inputs",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"{",
"\"input_ids\"",
":",
"inputs",
"}"
] | [
31,
4
] | [
36,
36
] | python | en | ['en', 'error', 'th'] | False |
TFGenerationMixin._use_cache | (self, outputs, use_cache) | During generation, decide whether to pass the `past` variable to the next forward pass. | During generation, decide whether to pass the `past` variable to the next forward pass. | def _use_cache(self, outputs, use_cache):
"""During generation, decide whether to pass the `past` variable to the next forward pass."""
use_cache = getattr(self.config, "use_cache", False)
if len(outputs) <= 1 or use_cache is False:
return False
if hasattr(self.config, "mem_l... | [
"def",
"_use_cache",
"(",
"self",
",",
"outputs",
",",
"use_cache",
")",
":",
"use_cache",
"=",
"getattr",
"(",
"self",
".",
"config",
",",
"\"use_cache\"",
",",
"False",
")",
"if",
"len",
"(",
"outputs",
")",
"<=",
"1",
"or",
"use_cache",
"is",
"False... | [
38,
4
] | [
45,
19
] | python | en | ['en', 'en', 'en'] | True |
TFGenerationMixin.generate | (
self,
input_ids=None,
max_length=None,
min_length=None,
do_sample=None,
early_stopping=None,
num_beams=None,
temperature=None,
top_k=None,
top_p=None,
repetition_penalty=None,
bad_words_ids=None,
bos_token_id=None,... | r"""
Generates sequences for models with a language modeling head. The method currently supports greedy decoding,
beam-search decoding, sampling with temperature, sampling with top-k or nucleus sampling.
Adapted in part from `Facebook's XLM beam search code
<https://github.com/facebookr... | r"""
Generates sequences for models with a language modeling head. The method currently supports greedy decoding,
beam-search decoding, sampling with temperature, sampling with top-k or nucleus sampling. | def generate(
self,
input_ids=None,
max_length=None,
min_length=None,
do_sample=None,
early_stopping=None,
num_beams=None,
temperature=None,
top_k=None,
top_p=None,
repetition_penalty=None,
bad_words_ids=None,
bos_to... | [
"def",
"generate",
"(",
"self",
",",
"input_ids",
"=",
"None",
",",
"max_length",
"=",
"None",
",",
"min_length",
"=",
"None",
",",
"do_sample",
"=",
"None",
",",
"early_stopping",
"=",
"None",
",",
"num_beams",
"=",
"None",
",",
"temperature",
"=",
"Non... | [
47,
4
] | [
421,
21
] | python | cy | ['en', 'cy', 'hi'] | False |
TFGenerationMixin._generate_no_beam_search | (
self,
input_ids,
cur_len,
max_length,
min_length,
do_sample,
temperature,
top_k,
top_p,
repetition_penalty,
no_repeat_ngram_size,
bad_words_ids,
pad_token_id,
eos_token_id,
batch_size,
vocab... |
Generate sequences for each example without beam search (num_beams == 1). All returned sequence are generated
independantly.
|
Generate sequences for each example without beam search (num_beams == 1). All returned sequence are generated
independantly.
| def _generate_no_beam_search(
self,
input_ids,
cur_len,
max_length,
min_length,
do_sample,
temperature,
top_k,
top_p,
repetition_penalty,
no_repeat_ngram_size,
bad_words_ids,
pad_token_id,
eos_token_id,
... | [
"def",
"_generate_no_beam_search",
"(",
"self",
",",
"input_ids",
",",
"cur_len",
",",
"max_length",
",",
"min_length",
",",
"do_sample",
",",
"temperature",
",",
"top_k",
",",
"top_p",
",",
"repetition_penalty",
",",
"no_repeat_ngram_size",
",",
"bad_words_ids",
... | [
423,
4
] | [
584,
22
] | python | en | ['en', 'error', 'th'] | False |
TFGenerationMixin._generate_beam_search | (
self,
input_ids,
cur_len,
max_length,
min_length,
do_sample,
early_stopping,
temperature,
top_k,
top_p,
repetition_penalty,
no_repeat_ngram_size,
bad_words_ids,
pad_token_id,
eos_token_id,
b... | Generate sequences for each example with beam search. | Generate sequences for each example with beam search. | def _generate_beam_search(
self,
input_ids,
cur_len,
max_length,
min_length,
do_sample,
early_stopping,
temperature,
top_k,
top_p,
repetition_penalty,
no_repeat_ngram_size,
bad_words_ids,
pad_token_id,
... | [
"def",
"_generate_beam_search",
"(",
"self",
",",
"input_ids",
",",
"cur_len",
",",
"max_length",
",",
"min_length",
",",
"do_sample",
",",
"early_stopping",
",",
"temperature",
",",
"top_k",
",",
"top_p",
",",
"repetition_penalty",
",",
"no_repeat_ngram_size",
",... | [
586,
4
] | [
913,
22
] | python | en | ['en', 'en', 'en'] | True |
TFGenerationMixin.adjust_logits_during_generation | (
self, logits, cur_len, max_length, forced_bos_token_id, forced_eos_token_id, **kwargs
) |
Implement in subclasses of :class:`~transformers.PreTrainedModel` for custom behavior to adjust the logits in
the generate method.
|
Implement in subclasses of :class:`~transformers.PreTrainedModel` for custom behavior to adjust the logits in
the generate method.
| def adjust_logits_during_generation(
self, logits, cur_len, max_length, forced_bos_token_id, forced_eos_token_id, **kwargs
):
"""
Implement in subclasses of :class:`~transformers.PreTrainedModel` for custom behavior to adjust the logits in
the generate method.
"""
if ... | [
"def",
"adjust_logits_during_generation",
"(",
"self",
",",
"logits",
",",
"cur_len",
",",
"max_length",
",",
"forced_bos_token_id",
",",
"forced_eos_token_id",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"cur_len",
"==",
"1",
"and",
"forced_bos_token_id",
"is",
"n... | [
919,
4
] | [
933,
25
] | python | en | ['en', 'error', 'th'] | False |
BeamHypotheses.__init__ | (self, num_beams, max_length, length_penalty, early_stopping) |
Initialize n-best list of hypotheses.
|
Initialize n-best list of hypotheses.
| def __init__(self, num_beams, max_length, length_penalty, early_stopping):
"""
Initialize n-best list of hypotheses.
"""
self.max_length = max_length - 1 # ignoring bos_token
self.length_penalty = length_penalty
self.early_stopping = early_stopping
self.num_beams... | [
"def",
"__init__",
"(",
"self",
",",
"num_beams",
",",
"max_length",
",",
"length_penalty",
",",
"early_stopping",
")",
":",
"self",
".",
"max_length",
"=",
"max_length",
"-",
"1",
"# ignoring bos_token",
"self",
".",
"length_penalty",
"=",
"length_penalty",
"se... | [
1096,
4
] | [
1105,
30
] | python | en | ['en', 'error', 'th'] | False |
BeamHypotheses.__len__ | (self) |
Number of hypotheses in the list.
|
Number of hypotheses in the list.
| def __len__(self):
"""
Number of hypotheses in the list.
"""
return len(self.beams) | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"beams",
")"
] | [
1107,
4
] | [
1111,
30
] | python | en | ['en', 'error', 'th'] | False |
BeamHypotheses.add | (self, hyp, sum_logprobs) |
Add a new hypothesis to the list.
|
Add a new hypothesis to the list.
| def add(self, hyp, sum_logprobs):
"""
Add a new hypothesis to the list.
"""
score = sum_logprobs / len(hyp) ** self.length_penalty
if len(self) < self.num_beams or score > self.worst_score:
self.beams.append((score, hyp))
if len(self) > self.num_beams:
... | [
"def",
"add",
"(",
"self",
",",
"hyp",
",",
"sum_logprobs",
")",
":",
"score",
"=",
"sum_logprobs",
"/",
"len",
"(",
"hyp",
")",
"**",
"self",
".",
"length_penalty",
"if",
"len",
"(",
"self",
")",
"<",
"self",
".",
"num_beams",
"or",
"score",
">",
... | [
1113,
4
] | [
1125,
63
] | python | en | ['en', 'error', 'th'] | False |
BeamHypotheses.is_done | (self, best_sum_logprobs, cur_len) |
If there are enough hypotheses and that none of the hypotheses being generated can become better than the worst
one in the heap, then we are done with this sentence.
|
If there are enough hypotheses and that none of the hypotheses being generated can become better than the worst
one in the heap, then we are done with this sentence.
| def is_done(self, best_sum_logprobs, cur_len):
"""
If there are enough hypotheses and that none of the hypotheses being generated can become better than the worst
one in the heap, then we are done with this sentence.
"""
if len(self) < self.num_beams:
return False
... | [
"def",
"is_done",
"(",
"self",
",",
"best_sum_logprobs",
",",
"cur_len",
")",
":",
"if",
"len",
"(",
"self",
")",
"<",
"self",
".",
"num_beams",
":",
"return",
"False",
"elif",
"self",
".",
"early_stopping",
":",
"return",
"True",
"else",
":",
"cur_score... | [
1127,
4
] | [
1140,
22
] | python | en | ['en', 'error', 'th'] | False |
async_get_triggers | (hass: HomeAssistant, device_id: str) | List device triggers for Climate devices. | List device triggers for Climate devices. | async def async_get_triggers(hass: HomeAssistant, device_id: str) -> List[dict]:
"""List device triggers for Climate devices."""
registry = await entity_registry.async_get_registry(hass)
triggers = []
# Get all the integrations entities for this device
for entry in entity_registry.async_entries_for... | [
"async",
"def",
"async_get_triggers",
"(",
"hass",
":",
"HomeAssistant",
",",
"device_id",
":",
"str",
")",
"->",
"List",
"[",
"dict",
"]",
":",
"registry",
"=",
"await",
"entity_registry",
".",
"async_get_registry",
"(",
"hass",
")",
"triggers",
"=",
"[",
... | [
60,
0
] | [
105,
19
] | python | en | ['fr', 'en', 'en'] | True |
async_attach_trigger | (
hass: HomeAssistant,
config: ConfigType,
action: AutomationActionType,
automation_info: dict,
) | Attach a trigger. | Attach a trigger. | async def async_attach_trigger(
hass: HomeAssistant,
config: ConfigType,
action: AutomationActionType,
automation_info: dict,
) -> CALLBACK_TYPE:
"""Attach a trigger."""
config = TRIGGER_SCHEMA(config)
trigger_type = config[CONF_TYPE]
if trigger_type == "hvac_mode_changed":
stat... | [
"async",
"def",
"async_attach_trigger",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
",",
"action",
":",
"AutomationActionType",
",",
"automation_info",
":",
"dict",
",",
")",
"->",
"CALLBACK_TYPE",
":",
"config",
"=",
"TRIGGER_SCHEMA",
"... | [
108,
0
] | [
160,
5
] | python | en | ['en', 'lb', 'en'] | True |
async_get_trigger_capabilities | (hass: HomeAssistant, config) | List trigger capabilities. | List trigger capabilities. | async def async_get_trigger_capabilities(hass: HomeAssistant, config):
"""List trigger capabilities."""
trigger_type = config[CONF_TYPE]
if trigger_type == "hvac_action_changed":
return None
if trigger_type == "hvac_mode_changed":
return {
"extra_fields": vol.Schema(
... | [
"async",
"def",
"async_get_trigger_capabilities",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
")",
":",
"trigger_type",
"=",
"config",
"[",
"CONF_TYPE",
"]",
"if",
"trigger_type",
"==",
"\"hvac_action_changed\"",
":",
"return",
"None",
"if",
"trigger_type",
... | [
163,
0
] | [
194,
5
] | python | en | ['en', 'la', 'en'] | True |
postprocess_qa_predictions | (
examples,
features,
predictions: Tuple[np.ndarray, np.ndarray],
version_2_with_negative: bool = False,
n_best_size: int = 20,
max_answer_length: int = 30,
null_score_diff_threshold: float = 0.0,
output_dir: Optional[str] = None,
prefix: Optional[str] = None,
is_world_process_ze... |
Post-processes the predictions of a question-answering model to convert them to answers that are substrings of the
original contexts. This is the base postprocessing functions for models that only return start and end logits.
Args:
examples: The non-preprocessed dataset (see the main script for mo... |
Post-processes the predictions of a question-answering model to convert them to answers that are substrings of the
original contexts. This is the base postprocessing functions for models that only return start and end logits. | def postprocess_qa_predictions(
examples,
features,
predictions: Tuple[np.ndarray, np.ndarray],
version_2_with_negative: bool = False,
n_best_size: int = 20,
max_answer_length: int = 30,
null_score_diff_threshold: float = 0.0,
output_dir: Optional[str] = None,
prefix: Optional[str] =... | [
"def",
"postprocess_qa_predictions",
"(",
"examples",
",",
"features",
",",
"predictions",
":",
"Tuple",
"[",
"np",
".",
"ndarray",
",",
"np",
".",
"ndarray",
"]",
",",
"version_2_with_negative",
":",
"bool",
"=",
"False",
",",
"n_best_size",
":",
"int",
"="... | [
30,
0
] | [
238,
26
] | python | en | ['en', 'error', 'th'] | False |
postprocess_qa_predictions_with_beam_search | (
examples,
features,
predictions: Tuple[np.ndarray, np.ndarray],
version_2_with_negative: bool = False,
n_best_size: int = 20,
max_answer_length: int = 30,
start_n_top: int = 5,
end_n_top: int = 5,
output_dir: Optional[str] = None,
prefix: Optional[str] = None,
is_world_proc... |
Post-processes the predictions of a question-answering model with beam search to convert them to answers that are substrings of the
original contexts. This is the postprocessing functions for models that return start and end logits, indices, as well as
cls token predictions.
Args:
examples: Th... |
Post-processes the predictions of a question-answering model with beam search to convert them to answers that are substrings of the
original contexts. This is the postprocessing functions for models that return start and end logits, indices, as well as
cls token predictions. | def postprocess_qa_predictions_with_beam_search(
examples,
features,
predictions: Tuple[np.ndarray, np.ndarray],
version_2_with_negative: bool = False,
n_best_size: int = 20,
max_answer_length: int = 30,
start_n_top: int = 5,
end_n_top: int = 5,
output_dir: Optional[str] = None,
... | [
"def",
"postprocess_qa_predictions_with_beam_search",
"(",
"examples",
",",
"features",
",",
"predictions",
":",
"Tuple",
"[",
"np",
".",
"ndarray",
",",
"np",
".",
"ndarray",
"]",
",",
"version_2_with_negative",
":",
"bool",
"=",
"False",
",",
"n_best_size",
":... | [
241,
0
] | [
426,
44
] | python | en | ['en', 'error', 'th'] | False |
get_decision_data | (experiment_name: str, episode: str, tick: str) | Get the decision data within one tick.
Args:
experiment_name (str): Name of the experiment expected to be displayed.
episode (str) : Number of the episode of expected data.
tick (str): Number of tick of expected data.
Returns:
Dataframe: Formatted decision value of current ... | Get the decision data within one tick. | def get_decision_data(experiment_name: str, episode: str, tick: str) -> pd.DataFrame:
"""Get the decision data within one tick.
Args:
experiment_name (str): Name of the experiment expected to be displayed.
episode (str) : Number of the episode of expected data.
tick (str): Number of tic... | [
"def",
"get_decision_data",
"(",
"experiment_name",
":",
"str",
",",
"episode",
":",
"str",
",",
"tick",
":",
"str",
")",
"->",
"pd",
".",
"DataFrame",
":",
"params",
"=",
"{",
"\"query\"",
":",
"f\"select {request_column.decision_header.value} from {experiment_name... | [
12,
0
] | [
35,
24
] | python | en | ['en', 'en', 'en'] | True |
get_acc_decision_data | (experiment_name: str, episode: str, start_tick: str, end_tick: str) | Get the decision data within a range.
Args:
experiment_name (str): Name of the experiment expected to be displayed.
episode (str) : Number of the episode of expected data.
start_tick (str): Number of tick to the start point of decision data.
end_tick(str): Number of tick to the end ... | Get the decision data within a range. | def get_acc_decision_data(experiment_name: str, episode: str, start_tick: str, end_tick: str) -> json:
"""Get the decision data within a range.
Args:
experiment_name (str): Name of the experiment expected to be displayed.
episode (str) : Number of the episode of expected data.
start_tic... | [
"def",
"get_acc_decision_data",
"(",
"experiment_name",
":",
"str",
",",
"episode",
":",
"str",
",",
"start_tick",
":",
"str",
",",
"end_tick",
":",
"str",
")",
"->",
"json",
":",
"input_range",
"=",
"get_input_range",
"(",
"start_tick",
",",
"end_tick",
")"... | [
38,
0
] | [
73,
26
] | python | en | ['en', 'en', 'en'] | True |
TFRagPreTrainedModel.from_pretrained_question_encoder_generator | (
cls,
question_encoder_pretrained_model_name_or_path: str = None,
generator_pretrained_model_name_or_path: str = None,
retriever: RagRetriever = None,
*model_args,
**kwargs
) | r"""
Instantiates an question encoder and a generator from one or two base classes of the library from pretrained
model checkpoints.
Params:
question_encoder_pretrained_model_name_or_path (:obj: `str`, `optional`):
Information necessary to initiate the question encod... | r"""
Instantiates an question encoder and a generator from one or two base classes of the library from pretrained
model checkpoints. | def from_pretrained_question_encoder_generator(
cls,
question_encoder_pretrained_model_name_or_path: str = None,
generator_pretrained_model_name_or_path: str = None,
retriever: RagRetriever = None,
*model_args,
**kwargs
) -> TFPreTrainedModel:
r"""
Ins... | [
"def",
"from_pretrained_question_encoder_generator",
"(",
"cls",
",",
"question_encoder_pretrained_model_name_or_path",
":",
"str",
"=",
"None",
",",
"generator_pretrained_model_name_or_path",
":",
"str",
"=",
"None",
",",
"retriever",
":",
"RagRetriever",
"=",
"None",
",... | [
222,
4
] | [
362,
110
] | python | cy | ['en', 'cy', 'hi'] | False |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up a BleBox entry. | Set up a BleBox entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up a BleBox entry."""
create_blebox_entities(
hass, config_entry, async_add_entities, BleBoxSensorEntity, "sensors"
) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"create_blebox_entities",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
",",
"BleBoxSensorEntity",
",",
"\"sensors\"",
")"
] | [
8,
0
] | [
13,
5
] | python | en | ['en', 'hu', 'en'] | True |
BleBoxSensorEntity.state | (self) | Return the state. | Return the state. | def state(self):
"""Return the state."""
return self._feature.current | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_feature",
".",
"current"
] | [
20,
4
] | [
22,
36
] | python | en | ['en', 'en', 'en'] | True |
BleBoxSensorEntity.unit_of_measurement | (self) | Return the unit. | Return the unit. | def unit_of_measurement(self):
"""Return the unit."""
return BLEBOX_TO_UNIT_MAP[self._feature.unit] | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"BLEBOX_TO_UNIT_MAP",
"[",
"self",
".",
"_feature",
".",
"unit",
"]"
] | [
25,
4
] | [
27,
53
] | python | en | ['en', 'sq', 'en'] | True |
BleBoxSensorEntity.device_class | (self) | Return the device class. | Return the device class. | def device_class(self):
"""Return the device class."""
return BLEBOX_TO_HASS_DEVICE_CLASSES[self._feature.device_class] | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"BLEBOX_TO_HASS_DEVICE_CLASSES",
"[",
"self",
".",
"_feature",
".",
"device_class",
"]"
] | [
30,
4
] | [
32,
72
] | python | en | ['en', 'en', 'en'] | True |
get_config | (host=DEVICE_1_IP, port=8090, name="soundtouch") | Return a default component. | Return a default component. | def get_config(host=DEVICE_1_IP, port=8090, name="soundtouch"):
"""Return a default component."""
return {"platform": DOMAIN, "host": host, "port": port, "name": name} | [
"def",
"get_config",
"(",
"host",
"=",
"DEVICE_1_IP",
",",
"port",
"=",
"8090",
",",
"name",
"=",
"\"soundtouch\"",
")",
":",
"return",
"{",
"\"platform\"",
":",
"DOMAIN",
",",
"\"host\"",
":",
"host",
",",
"\"port\"",
":",
"port",
",",
"\"name\"",
":",
... | [
39,
0
] | [
41,
73
] | python | en | ['es', 'fr', 'en'] | False |
one_device_fixture | () | Mock one master device. | Mock one master device. | def one_device_fixture():
"""Mock one master device."""
device_1 = MockDevice()
device_patch = patch(
"homeassistant.components.soundtouch.media_player.soundtouch_device",
return_value=device_1,
)
with device_patch as device:
yield device | [
"def",
"one_device_fixture",
"(",
")",
":",
"device_1",
"=",
"MockDevice",
"(",
")",
"device_patch",
"=",
"patch",
"(",
"\"homeassistant.components.soundtouch.media_player.soundtouch_device\"",
",",
"return_value",
"=",
"device_1",
",",
")",
"with",
"device_patch",
"as"... | [
49,
0
] | [
57,
20
] | python | en | ['nl', 'en', 'en'] | True |
two_zones_fixture | () | Mock one master and one slave. | Mock one master and one slave. | def two_zones_fixture():
"""Mock one master and one slave."""
device_1 = MockDevice(
DEVICE_1_ID,
MockZoneStatus(
is_master=True,
master_id=DEVICE_1_ID,
master_ip=DEVICE_1_IP,
slaves=[MockZoneSlave(DEVICE_2_IP)],
),
)
device_2 = Moc... | [
"def",
"two_zones_fixture",
"(",
")",
":",
"device_1",
"=",
"MockDevice",
"(",
"DEVICE_1_ID",
",",
"MockZoneStatus",
"(",
"is_master",
"=",
"True",
",",
"master_id",
"=",
"DEVICE_1_ID",
",",
"master_ip",
"=",
"DEVICE_1_IP",
",",
"slaves",
"=",
"[",
"MockZoneSl... | [
61,
0
] | [
87,
20
] | python | en | ['en', 'en', 'en'] | True |
status_fixture | () | Mock the device status. | Mock the device status. | def status_fixture():
"""Mock the device status."""
status_patch = patch(
"libsoundtouch.device.SoundTouchDevice.status", side_effect=MockStatusPlaying
)
with status_patch as status:
yield status | [
"def",
"status_fixture",
"(",
")",
":",
"status_patch",
"=",
"patch",
"(",
"\"libsoundtouch.device.SoundTouchDevice.status\"",
",",
"side_effect",
"=",
"MockStatusPlaying",
")",
"with",
"status_patch",
"as",
"status",
":",
"yield",
"status"
] | [
91,
0
] | [
97,
20
] | python | en | ['en', 'en', 'en'] | True |
volume_fixture | () | Mock the device volume. | Mock the device volume. | def volume_fixture():
"""Mock the device volume."""
volume_patch = patch("libsoundtouch.device.SoundTouchDevice.volume")
with volume_patch as volume:
yield volume | [
"def",
"volume_fixture",
"(",
")",
":",
"volume_patch",
"=",
"patch",
"(",
"\"libsoundtouch.device.SoundTouchDevice.volume\"",
")",
"with",
"volume_patch",
"as",
"volume",
":",
"yield",
"volume"
] | [
101,
0
] | [
105,
20
] | python | en | ['en', 'en', 'en'] | True |
setup_soundtouch | (hass, config) | Set up soundtouch integration. | Set up soundtouch integration. | async def setup_soundtouch(hass, config):
"""Set up soundtouch integration."""
assert await async_setup_component(hass, "media_player", {"media_player": config})
await hass.async_block_till_done()
await hass.async_start() | [
"async",
"def",
"setup_soundtouch",
"(",
"hass",
",",
"config",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"media_player\"",
",",
"{",
"\"media_player\"",
":",
"config",
"}",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",... | [
108,
0
] | [
112,
28
] | python | en | ['en', 'cs', 'en'] | True |
_mocked_presets | (*args, **kwargs) | Return a list of mocked presets. | Return a list of mocked presets. | def _mocked_presets(*args, **kwargs):
"""Return a list of mocked presets."""
return [MockPreset("1")] | [
"def",
"_mocked_presets",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"[",
"MockPreset",
"(",
"\"1\"",
")",
"]"
] | [
157,
0
] | [
159,
28
] | python | en | ['en', 'da', 'en'] | True |
test_ensure_setup_config | (mocked_status, mocked_volume, hass, one_device) | Test setup OK with custom config. | Test setup OK with custom config. | async def test_ensure_setup_config(mocked_status, mocked_volume, hass, one_device):
"""Test setup OK with custom config."""
await setup_soundtouch(
hass, get_config(host="192.168.1.44", port=8888, name="custom_sound")
)
assert one_device.call_count == 1
assert one_device.call_args == call("... | [
"async",
"def",
"test_ensure_setup_config",
"(",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"get_config",
"(",
"host",
"=",
"\"192.168.1.44\"",
",",
"port",
"=",
"8888",
",",
... | [
287,
0
] | [
297,
39
] | python | en | ['en', 'pt', 'en'] | True |
test_ensure_setup_discovery | (mocked_status, mocked_volume, hass, one_device) | Test setup with discovery. | Test setup with discovery. | async def test_ensure_setup_discovery(mocked_status, mocked_volume, hass, one_device):
"""Test setup with discovery."""
new_device = {
"port": "8090",
"host": "192.168.1.1",
"properties": {},
"hostname": "hostname.local",
}
await async_load_platform(
hass, "media_... | [
"async",
"def",
"test_ensure_setup_discovery",
"(",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"new_device",
"=",
"{",
"\"port\"",
":",
"\"8090\"",
",",
"\"host\"",
":",
"\"192.168.1.1\"",
",",
"\"properties\"",
":",
"{",
"}... | [
300,
0
] | [
315,
44
] | python | en | ['en', 'en', 'en'] | True |
test_ensure_setup_discovery_no_duplicate | (
mocked_status, mocked_volume, hass, one_device
) | Test setup OK if device already exists. | Test setup OK if device already exists. | async def test_ensure_setup_discovery_no_duplicate(
mocked_status, mocked_volume, hass, one_device
):
"""Test setup OK if device already exists."""
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert len(hass.states.async_all()) == 1
new_device = {
"p... | [
"async",
"def",
"test_ensure_setup_discovery_no_duplicate",
"(",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert",
"one_device",
".",
"call_count",
"==",
... | [
318,
0
] | [
351,
44
] | python | en | ['en', 'haw', 'en'] | True |
test_playing_media | (mocked_status, mocked_volume, hass, one_device) | Test playing media info. | Test playing media info. | async def test_playing_media(mocked_status, mocked_volume, hass, one_device):
"""Test playing media info."""
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_volume.call_count == 2
entity_1_state = hass.states.ge... | [
"async",
"def",
"test_playing_media",
"(",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert",
"one_device",
".",
"call_count",
"==",
"1",
"assert",
"mo... | [
354,
0
] | [
368,
59
] | python | en | ['en', 'en', 'en'] | True |
test_playing_unknown_media | (mocked_status, mocked_volume, hass, one_device) | Test playing media info. | Test playing media info. | async def test_playing_unknown_media(mocked_status, mocked_volume, hass, one_device):
"""Test playing media info."""
mocked_status.side_effect = MockStatusUnknown
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_v... | [
"async",
"def",
"test_playing_unknown_media",
"(",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"mocked_status",
".",
"side_effect",
"=",
"MockStatusUnknown",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
... | [
371,
0
] | [
381,
48
] | python | en | ['en', 'en', 'en'] | True |
test_playing_radio | (mocked_status, mocked_volume, hass, one_device) | Test playing radio info. | Test playing radio info. | async def test_playing_radio(mocked_status, mocked_volume, hass, one_device):
"""Test playing radio info."""
mocked_status.side_effect = MockStatusPlayingRadio
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_volu... | [
"async",
"def",
"test_playing_radio",
"(",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"mocked_status",
".",
"side_effect",
"=",
"MockStatusPlayingRadio",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"as... | [
384,
0
] | [
395,
64
] | python | en | ['it', 'tg', 'en'] | False |
test_playing_aux | (mocked_status, mocked_volume, hass, one_device) | Test playing AUX info. | Test playing AUX info. | async def test_playing_aux(mocked_status, mocked_volume, hass, one_device):
"""Test playing AUX info."""
mocked_status.side_effect = MockStatusPlayingAux
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_volume.cal... | [
"async",
"def",
"test_playing_aux",
"(",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"mocked_status",
".",
"side_effect",
"=",
"MockStatusPlayingAux",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert... | [
398,
0
] | [
409,
55
] | python | en | ['en', 'en', 'en'] | True |
test_playing_bluetooth | (mocked_status, mocked_volume, hass, one_device) | Test playing Bluetooth info. | Test playing Bluetooth info. | async def test_playing_bluetooth(mocked_status, mocked_volume, hass, one_device):
"""Test playing Bluetooth info."""
mocked_status.side_effect = MockStatusPlayingBluetooth
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert... | [
"async",
"def",
"test_playing_bluetooth",
"(",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"mocked_status",
".",
"side_effect",
"=",
"MockStatusPlayingBluetooth",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")... | [
412,
0
] | [
426,
67
] | python | en | ['en', 'en', 'en'] | True |
test_get_volume_level | (mocked_status, mocked_volume, hass, one_device) | Test volume level. | Test volume level. | async def test_get_volume_level(mocked_status, mocked_volume, hass, one_device):
"""Test volume level."""
mocked_volume.side_effect = MockVolume
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_volume.call_count =... | [
"async",
"def",
"test_get_volume_level",
"(",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"mocked_volume",
".",
"side_effect",
"=",
"MockVolume",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert",
... | [
429,
0
] | [
439,
60
] | python | de | ['fr', 'de', 'en'] | False |
test_get_state_off | (mocked_status, mocked_volume, hass, one_device) | Test state device is off. | Test state device is off. | async def test_get_state_off(mocked_status, mocked_volume, hass, one_device):
"""Test state device is off."""
mocked_status.side_effect = MockStatusStandby
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_volume.c... | [
"async",
"def",
"test_get_state_off",
"(",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"mocked_status",
".",
"side_effect",
"=",
"MockStatusStandby",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert"... | [
442,
0
] | [
452,
44
] | python | en | ['en', 'en', 'en'] | True |
test_get_state_pause | (mocked_status, mocked_volume, hass, one_device) | Test state device is paused. | Test state device is paused. | async def test_get_state_pause(mocked_status, mocked_volume, hass, one_device):
"""Test state device is paused."""
mocked_status.side_effect = MockStatusPause
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_volum... | [
"async",
"def",
"test_get_state_pause",
"(",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"mocked_status",
".",
"side_effect",
"=",
"MockStatusPause",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert"... | [
455,
0
] | [
465,
47
] | python | en | ['en', 'en', 'en'] | True |
test_is_muted | (mocked_status, mocked_volume, hass, one_device) | Test device volume is muted. | Test device volume is muted. | async def test_is_muted(mocked_status, mocked_volume, hass, one_device):
"""Test device volume is muted."""
mocked_volume.side_effect = MockVolumeMuted
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_volume.call_... | [
"async",
"def",
"test_is_muted",
"(",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"mocked_volume",
".",
"side_effect",
"=",
"MockVolumeMuted",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert",
"on... | [
468,
0
] | [
478,
55
] | python | en | ['nl', 'en', 'en'] | True |
test_media_commands | (mocked_status, mocked_volume, hass, one_device) | Test supported media commands. | Test supported media commands. | async def test_media_commands(mocked_status, mocked_volume, hass, one_device):
"""Test supported media commands."""
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_volume.call_count == 2
entity_1_state = hass.st... | [
"async",
"def",
"test_media_commands",
"(",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert",
"one_device",
".",
"call_count",
"==",
"1",
"assert",
"m... | [
481,
0
] | [
490,
67
] | python | en | ['it', 'en', 'en'] | True |
test_should_turn_off | (
mocked_power_off, mocked_status, mocked_volume, hass, one_device
) | Test device is turned off. | Test device is turned off. | async def test_should_turn_off(
mocked_power_off, mocked_status, mocked_volume, hass, one_device
):
"""Test device is turned off."""
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_volume.call_count == 2
awa... | [
"async",
"def",
"test_should_turn_off",
"(",
"mocked_power_off",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert",
"one_device",
".",
"call_count",
... | [
494,
0
] | [
511,
43
] | python | en | ['en', 'en', 'en'] | True |
test_should_turn_on | (
mocked_power_on, mocked_status, mocked_volume, hass, one_device
) | Test device is turned on. | Test device is turned on. | async def test_should_turn_on(
mocked_power_on, mocked_status, mocked_volume, hass, one_device
):
"""Test device is turned on."""
mocked_status.side_effect = MockStatusStandby
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
... | [
"async",
"def",
"test_should_turn_on",
"(",
"mocked_power_on",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"mocked_status",
".",
"side_effect",
"=",
"MockStatusStandby",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE... | [
515,
0
] | [
533,
42
] | python | en | ['en', 'en', 'en'] | True |
test_volume_up | (
mocked_volume_up, mocked_status, mocked_volume, hass, one_device
) | Test volume up. | Test volume up. | async def test_volume_up(
mocked_volume_up, mocked_status, mocked_volume, hass, one_device
):
"""Test volume up."""
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_volume.call_count == 2
await hass.services.... | [
"async",
"def",
"test_volume_up",
"(",
"mocked_volume_up",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert",
"one_device",
".",
"call_count",
"==",... | [
537,
0
] | [
554,
43
] | python | de | ['nl', 'de', 'en'] | False |
test_volume_down | (
mocked_volume_down, mocked_status, mocked_volume, hass, one_device
) | Test volume down. | Test volume down. | async def test_volume_down(
mocked_volume_down, mocked_status, mocked_volume, hass, one_device
):
"""Test volume down."""
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_volume.call_count == 2
await hass.ser... | [
"async",
"def",
"test_volume_down",
"(",
"mocked_volume_down",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert",
"one_device",
".",
"call_count",
"... | [
558,
0
] | [
575,
45
] | python | de | ['nl', 'de', 'en'] | False |
test_set_volume_level | (
mocked_set_volume, mocked_status, mocked_volume, hass, one_device
) | Test set volume level. | Test set volume level. | async def test_set_volume_level(
mocked_set_volume, mocked_status, mocked_volume, hass, one_device
):
"""Test set volume level."""
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_volume.call_count == 2
await... | [
"async",
"def",
"test_set_volume_level",
"(",
"mocked_set_volume",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert",
"one_device",
".",
"call_count",... | [
579,
0
] | [
596,
44
] | python | en | ['fr', 'ko', 'en'] | False |
test_mute | (mocked_mute, mocked_status, mocked_volume, hass, one_device) | Test mute volume. | Test mute volume. | async def test_mute(mocked_mute, mocked_status, mocked_volume, hass, one_device):
"""Test mute volume."""
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_volume.call_count == 2
await hass.services.async_call(
... | [
"async",
"def",
"test_mute",
"(",
"mocked_mute",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert",
"one_device",
".",
"call_count",
"==",
"1",
... | [
600,
0
] | [
615,
38
] | python | de | ['nl', 'de', 'en'] | False |
test_play | (mocked_play, mocked_status, mocked_volume, hass, one_device) | Test play command. | Test play command. | async def test_play(mocked_play, mocked_status, mocked_volume, hass, one_device):
"""Test play command."""
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_volume.call_count == 2
await hass.services.async_call(
... | [
"async",
"def",
"test_play",
"(",
"mocked_play",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert",
"one_device",
".",
"call_count",
"==",
"1",
... | [
619,
0
] | [
634,
38
] | python | en | ['en', 'en', 'en'] | True |
test_pause | (mocked_pause, mocked_status, mocked_volume, hass, one_device) | Test pause command. | Test pause command. | async def test_pause(mocked_pause, mocked_status, mocked_volume, hass, one_device):
"""Test pause command."""
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_volume.call_count == 2
await hass.services.async_call... | [
"async",
"def",
"test_pause",
"(",
"mocked_pause",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert",
"one_device",
".",
"call_count",
"==",
"1",
... | [
638,
0
] | [
653,
39
] | python | en | ['fr', 'en', 'en'] | True |
test_play_pause | (
mocked_play_pause, mocked_status, mocked_volume, hass, one_device
) | Test play/pause. | Test play/pause. | async def test_play_pause(
mocked_play_pause, mocked_status, mocked_volume, hass, one_device
):
"""Test play/pause."""
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_volume.call_count == 2
await hass.servic... | [
"async",
"def",
"test_play_pause",
"(",
"mocked_play_pause",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert",
"one_device",
".",
"call_count",
"==... | [
657,
0
] | [
674,
44
] | python | en | ['de', 'en', 'en'] | False |
test_next_previous_track | (
mocked_next_track,
mocked_previous_track,
mocked_status,
mocked_volume,
hass,
one_device,
) | Test next/previous track. | Test next/previous track. | async def test_next_previous_track(
mocked_next_track,
mocked_previous_track,
mocked_status,
mocked_volume,
hass,
one_device,
):
"""Test next/previous track."""
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
... | [
"async",
"def",
"test_next_previous_track",
"(",
"mocked_next_track",
",",
"mocked_previous_track",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
",",
")",
":",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"ass... | [
679,
0
] | [
710,
48
] | python | en | ['en', 'en', 'en'] | True |
test_play_media | (
mocked_presets, mocked_select_preset, mocked_status, mocked_volume, hass, one_device
) | Test play preset 1. | Test play preset 1. | async def test_play_media(
mocked_presets, mocked_select_preset, mocked_status, mocked_volume, hass, one_device
):
"""Test play preset 1."""
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_volume.call_count == 2
... | [
"async",
"def",
"test_play_media",
"(",
"mocked_presets",
",",
"mocked_select_preset",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert",
"one_device"... | [
715,
0
] | [
749,
47
] | python | be | ['de', 'be', 'it'] | False |
test_play_media_url | (
mocked_play_url, mocked_status, mocked_volume, hass, one_device
) | Test play preset 1. | Test play preset 1. | async def test_play_media_url(
mocked_play_url, mocked_status, mocked_volume, hass, one_device
):
"""Test play preset 1."""
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert one_device.call_count == 1
assert mocked_status.call_count == 2
assert mocked_volume.call_count == 2
await hass.s... | [
"async",
"def",
"test_play_media_url",
"(",
"mocked_play_url",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert",
"one_device",
".",
"call_count",
"... | [
753,
0
] | [
773,
62
] | python | be | ['de', 'be', 'it'] | False |
test_select_source_aux | (
mocked_select_source_aux, mocked_status, mocked_volume, hass, one_device
) | Test select AUX. | Test select AUX. | async def test_select_source_aux(
mocked_select_source_aux, mocked_status, mocked_volume, hass, one_device
):
"""Test select AUX."""
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert mocked_select_source_aux.call_count == 0
await hass.services.async_call(
"media_player",
"select_... | [
"async",
"def",
"test_select_source_aux",
"(",
"mocked_select_source_aux",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert",
"mocked_select_source_aux",
... | [
777,
0
] | [
791,
51
] | python | en | ['en', 'fr', 'en'] | True |
test_select_source_bluetooth | (
mocked_select_source_bluetooth, mocked_status, mocked_volume, hass, one_device
) | Test select Bluetooth. | Test select Bluetooth. | async def test_select_source_bluetooth(
mocked_select_source_bluetooth, mocked_status, mocked_volume, hass, one_device
):
"""Test select Bluetooth."""
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert mocked_select_source_bluetooth.call_count == 0
await hass.services.async_call(
"media_p... | [
"async",
"def",
"test_select_source_bluetooth",
"(",
"mocked_select_source_bluetooth",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
")",
":",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE_1_CONFIG",
")",
"assert",
"mocked_select_s... | [
795,
0
] | [
809,
57
] | python | en | ['en', 'en', 'en'] | True |
test_select_source_invalid_source | (
mocked_select_source_aux,
mocked_select_source_bluetooth,
mocked_status,
mocked_volume,
hass,
one_device,
) | Test select unsupported source. | Test select unsupported source. | async def test_select_source_invalid_source(
mocked_select_source_aux,
mocked_select_source_bluetooth,
mocked_status,
mocked_volume,
hass,
one_device,
):
"""Test select unsupported source."""
await setup_soundtouch(hass, DEVICE_1_CONFIG)
assert mocked_select_source_aux.call_count ==... | [
"async",
"def",
"test_select_source_invalid_source",
"(",
"mocked_select_source_aux",
",",
"mocked_select_source_bluetooth",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"one_device",
",",
")",
":",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"DEVICE... | [
814,
0
] | [
839,
57
] | python | en | ['fr', 'en', 'en'] | True |
test_play_everywhere | (
mocked_create_zone, mocked_status, mocked_volume, hass, two_zones
) | Test play everywhere. | Test play everywhere. | async def test_play_everywhere(
mocked_create_zone, mocked_status, mocked_volume, hass, two_zones
):
"""Test play everywhere."""
mocked_device = two_zones
await setup_soundtouch(hass, [DEVICE_1_CONFIG, DEVICE_2_CONFIG])
assert mocked_device.call_count == 2
assert mocked_status.call_count == 4
... | [
"async",
"def",
"test_play_everywhere",
"(",
"mocked_create_zone",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"two_zones",
")",
":",
"mocked_device",
"=",
"two_zones",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"[",
"DEVICE_1_CONFIG",
",",
"... | [
843,
0
] | [
884,
45
] | python | en | ['en', 'be', 'en'] | True |
test_create_zone | (
mocked_create_zone, mocked_status, mocked_volume, hass, two_zones
) | Test creating a zone. | Test creating a zone. | async def test_create_zone(
mocked_create_zone, mocked_status, mocked_volume, hass, two_zones
):
"""Test creating a zone."""
mocked_device = two_zones
await setup_soundtouch(hass, [DEVICE_1_CONFIG, DEVICE_2_CONFIG])
assert mocked_device.call_count == 2
assert mocked_status.call_count == 4
a... | [
"async",
"def",
"test_create_zone",
"(",
"mocked_create_zone",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"two_zones",
")",
":",
"mocked_device",
"=",
"two_zones",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"[",
"DEVICE_1_CONFIG",
",",
"DEVI... | [
888,
0
] | [
927,
45
] | python | en | ['en', 'en', 'en'] | True |
test_remove_zone_slave | (
mocked_remove_zone_slave, mocked_status, mocked_volume, hass, two_zones
) | Test adding a slave to an existing zone. | Test adding a slave to an existing zone. | async def test_remove_zone_slave(
mocked_remove_zone_slave, mocked_status, mocked_volume, hass, two_zones
):
"""Test adding a slave to an existing zone."""
mocked_device = two_zones
await setup_soundtouch(hass, [DEVICE_1_CONFIG, DEVICE_2_CONFIG])
assert mocked_device.call_count == 2
assert mock... | [
"async",
"def",
"test_remove_zone_slave",
"(",
"mocked_remove_zone_slave",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"two_zones",
")",
":",
"mocked_device",
"=",
"two_zones",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"[",
"DEVICE_1_CONFIG",
... | [
931,
0
] | [
970,
51
] | python | en | ['en', 'en', 'en'] | True |
test_add_zone_slave | (
mocked_add_zone_slave,
mocked_status,
mocked_volume,
hass,
two_zones,
) | Test removing a slave from a zone. | Test removing a slave from a zone. | async def test_add_zone_slave(
mocked_add_zone_slave,
mocked_status,
mocked_volume,
hass,
two_zones,
):
"""Test removing a slave from a zone."""
mocked_device = two_zones
await setup_soundtouch(hass, [DEVICE_1_CONFIG, DEVICE_2_CONFIG])
assert mocked_device.call_count == 2
assert... | [
"async",
"def",
"test_add_zone_slave",
"(",
"mocked_add_zone_slave",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"two_zones",
",",
")",
":",
"mocked_device",
"=",
"two_zones",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"[",
"DEVICE_1_CONFIG",
... | [
974,
0
] | [
1017,
48
] | python | en | ['en', 'en', 'en'] | True |
test_zone_attributes | (
mocked_create_zone,
mocked_status,
mocked_volume,
hass,
two_zones,
) | Test play everywhere. | Test play everywhere. | async def test_zone_attributes(
mocked_create_zone,
mocked_status,
mocked_volume,
hass,
two_zones,
):
"""Test play everywhere."""
mocked_device = two_zones
await setup_soundtouch(hass, [DEVICE_1_CONFIG, DEVICE_2_CONFIG])
assert mocked_device.call_count == 2
assert mocked_status.... | [
"async",
"def",
"test_zone_attributes",
"(",
"mocked_create_zone",
",",
"mocked_status",
",",
"mocked_volume",
",",
"hass",
",",
"two_zones",
",",
")",
":",
"mocked_device",
"=",
"two_zones",
"await",
"setup_soundtouch",
"(",
"hass",
",",
"[",
"DEVICE_1_CONFIG",
"... | [
1021,
0
] | [
1061,
5
] | python | en | ['en', 'be', 'en'] | True |
MockDevice.__init__ | (self, id=None, zone_status=None) | Init the class. | Init the class. | def __init__(self, id=None, zone_status=None):
"""Init the class."""
self._config = MockConfig(id)
self._zone_status = zone_status or MockZoneStatus() | [
"def",
"__init__",
"(",
"self",
",",
"id",
"=",
"None",
",",
"zone_status",
"=",
"None",
")",
":",
"self",
".",
"_config",
"=",
"MockConfig",
"(",
"id",
")",
"self",
".",
"_zone_status",
"=",
"zone_status",
"or",
"MockZoneStatus",
"(",
")"
] | [
118,
4
] | [
121,
59
] | python | en | ['en', 'en', 'en'] | True |
MockDevice.zone_status | (self, refresh=True) | Zone status mock object. | Zone status mock object. | def zone_status(self, refresh=True):
"""Zone status mock object."""
return self._zone_status | [
"def",
"zone_status",
"(",
"self",
",",
"refresh",
"=",
"True",
")",
":",
"return",
"self",
".",
"_zone_status"
] | [
123,
4
] | [
125,
32
] | python | en | ['pl', 'fy', 'en'] | False |
MockConfig.__init__ | (self, id=None) | Init class. | Init class. | def __init__(self, id=None):
"""Init class."""
self._name = "name"
self._id = id or DEVICE_1_ID | [
"def",
"__init__",
"(",
"self",
",",
"id",
"=",
"None",
")",
":",
"self",
".",
"_name",
"=",
"\"name\"",
"self",
".",
"_id",
"=",
"id",
"or",
"DEVICE_1_ID"
] | [
131,
4
] | [
134,
36
] | python | en | ['en', 'mt', 'en'] | False |
MockZoneStatus.__init__ | (self, is_master=True, master_id=None, master_ip=None, slaves=None) | Init the class. | Init the class. | def __init__(self, is_master=True, master_id=None, master_ip=None, slaves=None):
"""Init the class."""
self._is_master = is_master
self._master_id = master_id
self._master_ip = master_ip
self._slaves = slaves or [] | [
"def",
"__init__",
"(",
"self",
",",
"is_master",
"=",
"True",
",",
"master_id",
"=",
"None",
",",
"master_ip",
"=",
"None",
",",
"slaves",
"=",
"None",
")",
":",
"self",
".",
"_is_master",
"=",
"is_master",
"self",
".",
"_master_id",
"=",
"master_id",
... | [
140,
4
] | [
145,
35
] | python | en | ['en', 'en', 'en'] | True |
MockZoneSlave.__init__ | (self, device_ip=None, role=None) | Init the class. | Init the class. | def __init__(self, device_ip=None, role=None):
"""Init the class."""
self._ip = device_ip
self._role = role | [
"def",
"__init__",
"(",
"self",
",",
"device_ip",
"=",
"None",
",",
"role",
"=",
"None",
")",
":",
"self",
".",
"_ip",
"=",
"device_ip",
"self",
".",
"_role",
"=",
"role"
] | [
151,
4
] | [
154,
25
] | 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.