Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
async_setup_entry | (hass: HomeAssistantType, entry: ConfigEntry) | Set up Aqualink from a config entry. | Set up Aqualink from a config entry. | async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> None:
"""Set up Aqualink from a config entry."""
username = entry.data[CONF_USERNAME]
password = entry.data[CONF_PASSWORD]
# These will contain the initialized devices
binary_sensors = hass.data[DOMAIN][BINARY_SENSOR_DOMAIN... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"None",
":",
"username",
"=",
"entry",
".",
"data",
"[",
"CONF_USERNAME",
"]",
"password",
"=",
"entry",
".",
"data",
"[",
"CONF_PASSWORD... | [
74,
0
] | [
154,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistantType, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
forward_unload = hass.config_entries.async_forward_entry_unload
tasks = []
if hass.data[DOMAIN][BINARY_SENSOR_DOMAIN]:
tasks += [forward_unload(entry, BINARY_SENSOR_DOMAIN)]
if h... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"forward_unload",
"=",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload",
"tasks",
"=",
"[",
"]",
"if",
"hass",
... | [
157,
0
] | [
176,
44
] | python | en | ['en', 'es', 'en'] | True |
refresh_system | (func) | Force update all entities after state change. | Force update all entities after state change. | def refresh_system(func):
"""Force update all entities after state change."""
@wraps(func)
async def wrapper(self, *args, **kwargs):
"""Call decorated function and send update signal to all entities."""
await func(self, *args, **kwargs)
async_dispatcher_send(self.hass, DOMAIN)
... | [
"def",
"refresh_system",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"async",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Call decorated function and send update signal to all entities.\"\"\"",
"await",
"... | [
179,
0
] | [
188,
18
] | python | en | ['en', 'en', 'en'] | True |
AqualinkEntity.__init__ | (self, dev: AqualinkDevice) | Initialize the entity. | Initialize the entity. | def __init__(self, dev: AqualinkDevice):
"""Initialize the entity."""
self.dev = dev | [
"def",
"__init__",
"(",
"self",
",",
"dev",
":",
"AqualinkDevice",
")",
":",
"self",
".",
"dev",
"=",
"dev"
] | [
201,
4
] | [
203,
22
] | python | en | ['en', 'en', 'en'] | True |
AqualinkEntity.async_added_to_hass | (self) | Set up a listener when this entity is added to HA. | Set up a listener when this entity is added to HA. | async def async_added_to_hass(self) -> None:
"""Set up a listener when this entity is added to HA."""
self.async_on_remove(
async_dispatcher_connect(self.hass, DOMAIN, self.async_write_ha_state)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"DOMAIN",
",",
"self",
".",
"async_write_ha_state",
")",
")"
] | [
205,
4
] | [
209,
9
] | python | en | ['en', 'en', 'en'] | True |
AqualinkEntity.should_poll | (self) | Return False as entities shouldn't be polled.
Entities are checked periodically as the integration runs periodic
updates on a timer.
| Return False as entities shouldn't be polled. | def should_poll(self) -> bool:
"""Return False as entities shouldn't be polled.
Entities are checked periodically as the integration runs periodic
updates on a timer.
"""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
212,
4
] | [
218,
20
] | python | en | ['en', 'en', 'en'] | True |
AqualinkEntity.unique_id | (self) | Return a unique identifier for this entity. | Return a unique identifier for this entity. | def unique_id(self) -> str:
"""Return a unique identifier for this entity."""
return f"{self.dev.system.serial}_{self.dev.name}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self.dev.system.serial}_{self.dev.name}\""
] | [
221,
4
] | [
223,
58
] | python | en | ['en', 'fr', 'en'] | True |
AqualinkEntity.assumed_state | (self) | Return whether the state is based on actual reading from the device. | Return whether the state is based on actual reading from the device. | def assumed_state(self) -> bool:
"""Return whether the state is based on actual reading from the device."""
return not self.dev.system.last_run_success | [
"def",
"assumed_state",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"not",
"self",
".",
"dev",
".",
"system",
".",
"last_run_success"
] | [
226,
4
] | [
228,
51
] | python | en | ['en', 'en', 'en'] | True |
AqualinkEntity.available | (self) | Return whether the device is available or not. | Return whether the device is available or not. | def available(self) -> bool:
"""Return whether the device is available or not."""
return self.dev.system.online | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"dev",
".",
"system",
".",
"online"
] | [
231,
4
] | [
233,
37
] | python | en | ['en', 'en', 'en'] | True |
AqualinkEntity.device_info | (self) | Return the device info. | Return the device info. | def device_info(self) -> Dict[str, Any]:
"""Return the device info."""
return {
"identifiers": {(DOMAIN, self.unique_id)},
"name": self.name,
"model": self.dev.__class__.__name__.replace("Aqualink", ""),
"manufacturer": "Jandy",
"via_device": (... | [
"def",
"device_info",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"unique_id",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"name",
",",
"\"model\"",
... | [
236,
4
] | [
244,
9
] | python | en | ['en', 'en', 'en'] | True |
validate_input | (hass: core.HomeAssistant, data) | Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
| Validate the user input allows us to connect. | async def validate_input(hass: core.HomeAssistant, data):
"""Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
"""
websession = aiohttp_client.async_get_clientsession(hass)
try:
await pymyq.login(data[CONF_USERNAME], data[CO... | [
"async",
"def",
"validate_input",
"(",
"hass",
":",
"core",
".",
"HomeAssistant",
",",
"data",
")",
":",
"websession",
"=",
"aiohttp_client",
".",
"async_get_clientsession",
"(",
"hass",
")",
"try",
":",
"await",
"pymyq",
".",
"login",
"(",
"data",
"[",
"C... | [
20,
0
] | [
35,
41
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_user | (self, user_input=None) | Handle the initial step. | Handle the initial step. | async def async_step_user(self, user_input=None):
"""Handle the initial step."""
errors = {}
if user_input is not None:
try:
info = await validate_input(self.hass, user_input)
except CannotConnect:
errors["base"] = "cannot_connect"
... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"try",
":",
"info",
"=",
"await",
"validate_input",
"(",
"self",
".",
"hass",
",",
"user_in... | [
44,
4
] | [
65,
9
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_homekit | (self, homekit_info) | Handle HomeKit discovery. | Handle HomeKit discovery. | async def async_step_homekit(self, homekit_info):
"""Handle HomeKit discovery."""
if self._async_current_entries():
# We can see myq on the network to tell them to configure
# it, but since the device will not give up the account it is
# bound to and there can be mult... | [
"async",
"def",
"async_step_homekit",
"(",
"self",
",",
"homekit_info",
")",
":",
"if",
"self",
".",
"_async_current_entries",
"(",
")",
":",
"# We can see myq on the network to tell them to configure",
"# it, but since the device will not give up the account it is",
"# bound to ... | [
67,
4
] | [
81,
43
] | python | en | ['fr', 'xh', 'en'] | False |
ConfigFlow.async_step_import | (self, user_input) | Handle import. | Handle import. | async def async_step_import(self, user_input):
"""Handle import."""
await self.async_set_unique_id(user_input[CONF_USERNAME])
self._abort_if_unique_id_configured()
return await self.async_step_user(user_input) | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"user_input",
")",
":",
"await",
"self",
".",
"async_set_unique_id",
"(",
"user_input",
"[",
"CONF_USERNAME",
"]",
")",
"self",
".",
"_abort_if_unique_id_configured",
"(",
")",
"return",
"await",
"self",
"."... | [
83,
4
] | [
87,
53
] | python | en | ['en', 'ja', 'en'] | False |
setup_demo_vacuum | (hass) | Initialize setup demo vacuum. | Initialize setup demo vacuum. | async def setup_demo_vacuum(hass):
"""Initialize setup demo vacuum."""
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "demo"}})
await hass.async_block_till_done() | [
"async",
"def",
"setup_demo_vacuum",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"{",
"DOMAIN",
":",
"{",
"CONF_PLATFORM",
":",
"\"demo\"",
"}",
"}",
")",
"await",
"hass",
".",
"async_block_till_done",
... | [
50,
0
] | [
53,
38
] | python | en | ['en', 'la', 'en'] | True |
test_supported_features | (hass) | Test vacuum supported features. | Test vacuum supported features. | async def test_supported_features(hass):
"""Test vacuum supported features."""
state = hass.states.get(ENTITY_VACUUM_COMPLETE)
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == 2047
assert state.attributes.get(ATTR_STATUS) == "Charging"
assert state.attributes.get(ATTR_BATTERY_LEVEL) == 100
... | [
"async",
"def",
"test_supported_features",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_VACUUM_COMPLETE",
")",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_SUPPORTED_FEATURES",
")",
"==",
"2047",
"assert"... | [
56,
0
] | [
103,
66
] | python | en | ['en', 'en', 'en'] | True |
test_methods | (hass) | Test if methods call the services as expected. | Test if methods call the services as expected. | async def test_methods(hass):
"""Test if methods call the services as expected."""
hass.states.async_set(ENTITY_VACUUM_BASIC, STATE_ON)
await hass.async_block_till_done()
assert vacuum.is_on(hass, ENTITY_VACUUM_BASIC)
hass.states.async_set(ENTITY_VACUUM_BASIC, STATE_OFF)
await hass.async_block_... | [
"async",
"def",
"test_methods",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"ENTITY_VACUUM_BASIC",
",",
"STATE_ON",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
"assert",
"vacuum",
".",
"is_on",
"(",
"hass",
",",
"... | [
106,
0
] | [
185,
40
] | python | en | ['en', 'en', 'en'] | True |
test_unsupported_methods | (hass) | Test service calls for unsupported vacuums. | Test service calls for unsupported vacuums. | async def test_unsupported_methods(hass):
"""Test service calls for unsupported vacuums."""
hass.states.async_set(ENTITY_VACUUM_NONE, STATE_ON)
await hass.async_block_till_done()
assert vacuum.is_on(hass, ENTITY_VACUUM_NONE)
await common.async_turn_off(hass, ENTITY_VACUUM_NONE)
assert vacuum.is... | [
"async",
"def",
"test_unsupported_methods",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"ENTITY_VACUUM_NONE",
",",
"STATE_ON",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
"assert",
"vacuum",
".",
"is_on",
"(",
"hass",... | [
188,
0
] | [
257,
40
] | python | en | ['en', 'en', 'en'] | True |
test_services | (hass) | Test vacuum services. | Test vacuum services. | async def test_services(hass):
"""Test vacuum services."""
# Test send_command
send_command_calls = async_mock_service(hass, DOMAIN, SERVICE_SEND_COMMAND)
params = {"rotate": 150, "speed": 20}
await common.async_send_command(
hass, "test_command", entity_id=ENTITY_VACUUM_BASIC, params=param... | [
"async",
"def",
"test_services",
"(",
"hass",
")",
":",
"# Test send_command",
"send_command_calls",
"=",
"async_mock_service",
"(",
"hass",
",",
"DOMAIN",
",",
"SERVICE_SEND_COMMAND",
")",
"params",
"=",
"{",
"\"rotate\"",
":",
"150",
",",
"\"speed\"",
":",
"20... | [
260,
0
] | [
290,
53
] | python | en | ['nl', 'la', 'en'] | False |
test_set_fan_speed | (hass) | Test vacuum service to set the fan speed. | Test vacuum service to set the fan speed. | async def test_set_fan_speed(hass):
"""Test vacuum service to set the fan speed."""
group_vacuums = ",".join(
[ENTITY_VACUUM_BASIC, ENTITY_VACUUM_COMPLETE, ENTITY_VACUUM_STATE]
)
old_state_basic = hass.states.get(ENTITY_VACUUM_BASIC)
old_state_complete = hass.states.get(ENTITY_VACUUM_COMPLET... | [
"async",
"def",
"test_set_fan_speed",
"(",
"hass",
")",
":",
"group_vacuums",
"=",
"\",\"",
".",
"join",
"(",
"[",
"ENTITY_VACUUM_BASIC",
",",
"ENTITY_VACUUM_COMPLETE",
",",
"ENTITY_VACUUM_STATE",
"]",
")",
"old_state_basic",
"=",
"hass",
".",
"states",
".",
"ge... | [
293,
0
] | [
317,
70
] | python | en | ['en', 'en', 'en'] | True |
test_send_command | (hass) | Test vacuum service to send a command. | Test vacuum service to send a command. | async def test_send_command(hass):
"""Test vacuum service to send a command."""
group_vacuums = ",".join([ENTITY_VACUUM_BASIC, ENTITY_VACUUM_COMPLETE])
old_state_basic = hass.states.get(ENTITY_VACUUM_BASIC)
old_state_complete = hass.states.get(ENTITY_VACUUM_COMPLETE)
await common.async_send_command... | [
"async",
"def",
"test_send_command",
"(",
"hass",
")",
":",
"group_vacuums",
"=",
"\",\"",
".",
"join",
"(",
"[",
"ENTITY_VACUUM_BASIC",
",",
"ENTITY_VACUUM_COMPLETE",
"]",
")",
"old_state_basic",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_VACUUM_BASIC... | [
320,
0
] | [
339,
5
] | python | en | ['en', 'en', 'en'] | True |
FeatureExtractionPipeline.__call__ | (self, *args, **kwargs) |
Extract the features of the input(s).
Args:
args (:obj:`str` or :obj:`List[str]`): One or several texts (or one list of texts) to get the features of.
Return:
A nested list of :obj:`float`: The features computed by the model.
|
Extract the features of the input(s). | def __call__(self, *args, **kwargs):
"""
Extract the features of the input(s).
Args:
args (:obj:`str` or :obj:`List[str]`): One or several texts (or one list of texts) to get the features of.
Return:
A nested list of :obj:`float`: The features computed by the mo... | [
"def",
"__call__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
")",
".",
"__call__",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
".",
"tolist",
"(",
")"
] | [
71,
4
] | [
81,
57
] | python | en | ['en', 'error', 'th'] | False |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the buienradar platform. | Set up the buienradar platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the buienradar platform."""
latitude = config.get(CONF_LATITUDE, hass.config.latitude)
longitude = config.get(CONF_LONGITUDE, hass.config.longitude)
if None in (latitude, longitude):
_LOGGER.error("... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"latitude",
"=",
"config",
".",
"get",
"(",
"CONF_LATITUDE",
",",
"hass",
".",
"config",
".",
"latitude",
")",
"longi... | [
68,
0
] | [
95,
33
] | python | en | ['en', 'lv', 'en'] | True |
BrWeather.__init__ | (self, data, config, coordinates) | Initialise the platform with a data instance and station name. | Initialise the platform with a data instance and station name. | def __init__(self, data, config, coordinates):
"""Initialise the platform with a data instance and station name."""
self._stationname = config.get(CONF_NAME)
self._forecast = config[CONF_FORECAST]
self._data = data
self._unique_id = "{:2.6f}{:2.6f}".format(
coordinat... | [
"def",
"__init__",
"(",
"self",
",",
"data",
",",
"config",
",",
"coordinates",
")",
":",
"self",
".",
"_stationname",
"=",
"config",
".",
"get",
"(",
"CONF_NAME",
")",
"self",
".",
"_forecast",
"=",
"config",
"[",
"CONF_FORECAST",
"]",
"self",
".",
"_... | [
101,
4
] | [
109,
9
] | python | en | ['en', 'en', 'en'] | True |
BrWeather.attribution | (self) | Return the attribution. | Return the attribution. | def attribution(self):
"""Return the attribution."""
return self._data.attribution | [
"def",
"attribution",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
".",
"attribution"
] | [
112,
4
] | [
114,
37
] | python | en | ['en', 'ja', 'en'] | True |
BrWeather.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return (
self._stationname or f"BR {self._data.stationname or '(unknown station)'}"
) | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"_stationname",
"or",
"f\"BR {self._data.stationname or '(unknown station)'}\"",
")"
] | [
117,
4
] | [
121,
9
] | python | en | ['en', 'mi', 'en'] | True |
BrWeather.condition | (self) | Return the current condition. | Return the current condition. | def condition(self):
"""Return the current condition."""
if self._data and self._data.condition:
ccode = self._data.condition.get(CONDCODE)
if ccode:
conditions = self.hass.data.get(DATA_CONDITION)
if conditions:
return conditio... | [
"def",
"condition",
"(",
"self",
")",
":",
"if",
"self",
".",
"_data",
"and",
"self",
".",
"_data",
".",
"condition",
":",
"ccode",
"=",
"self",
".",
"_data",
".",
"condition",
".",
"get",
"(",
"CONDCODE",
")",
"if",
"ccode",
":",
"conditions",
"=",
... | [
124,
4
] | [
131,
48
] | python | en | ['en', 'en', 'en'] | True |
BrWeather.temperature | (self) | Return the current temperature. | Return the current temperature. | def temperature(self):
"""Return the current temperature."""
return self._data.temperature | [
"def",
"temperature",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
".",
"temperature"
] | [
134,
4
] | [
136,
37
] | python | en | ['en', 'la', 'en'] | True |
BrWeather.pressure | (self) | Return the current pressure. | Return the current pressure. | def pressure(self):
"""Return the current pressure."""
return self._data.pressure | [
"def",
"pressure",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
".",
"pressure"
] | [
139,
4
] | [
141,
34
] | python | en | ['en', 'co', 'en'] | True |
BrWeather.humidity | (self) | Return the name of the sensor. | Return the name of the sensor. | def humidity(self):
"""Return the name of the sensor."""
return self._data.humidity | [
"def",
"humidity",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
".",
"humidity"
] | [
144,
4
] | [
146,
34
] | python | en | ['en', 'mi', 'en'] | True |
BrWeather.visibility | (self) | Return the current visibility in km. | Return the current visibility in km. | def visibility(self):
"""Return the current visibility in km."""
if self._data.visibility is None:
return None
return round(self._data.visibility / 1000, 1) | [
"def",
"visibility",
"(",
"self",
")",
":",
"if",
"self",
".",
"_data",
".",
"visibility",
"is",
"None",
":",
"return",
"None",
"return",
"round",
"(",
"self",
".",
"_data",
".",
"visibility",
"/",
"1000",
",",
"1",
")"
] | [
149,
4
] | [
153,
53
] | python | en | ['en', 'en', 'en'] | True |
BrWeather.wind_speed | (self) | Return the current windspeed in km/h. | Return the current windspeed in km/h. | def wind_speed(self):
"""Return the current windspeed in km/h."""
if self._data.wind_speed is None:
return None
return round(self._data.wind_speed * 3.6, 1) | [
"def",
"wind_speed",
"(",
"self",
")",
":",
"if",
"self",
".",
"_data",
".",
"wind_speed",
"is",
"None",
":",
"return",
"None",
"return",
"round",
"(",
"self",
".",
"_data",
".",
"wind_speed",
"*",
"3.6",
",",
"1",
")"
] | [
156,
4
] | [
160,
52
] | python | en | ['en', 'co', 'en'] | True |
BrWeather.wind_bearing | (self) | Return the current wind bearing (degrees). | Return the current wind bearing (degrees). | def wind_bearing(self):
"""Return the current wind bearing (degrees)."""
return self._data.wind_bearing | [
"def",
"wind_bearing",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
".",
"wind_bearing"
] | [
163,
4
] | [
165,
38
] | python | en | ['en', 'en', 'en'] | True |
BrWeather.temperature_unit | (self) | Return the unit of measurement. | Return the unit of measurement. | def temperature_unit(self):
"""Return the unit of measurement."""
return TEMP_CELSIUS | [
"def",
"temperature_unit",
"(",
"self",
")",
":",
"return",
"TEMP_CELSIUS"
] | [
168,
4
] | [
170,
27
] | python | en | ['en', 'la', 'en'] | True |
BrWeather.forecast | (self) | Return the forecast array. | Return the forecast array. | def forecast(self):
"""Return the forecast array."""
if not self._forecast:
return None
fcdata_out = []
cond = self.hass.data[DATA_CONDITION]
if not self._data.forecast:
return None
for data_in in self._data.forecast:
# remap keys fr... | [
"def",
"forecast",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_forecast",
":",
"return",
"None",
"fcdata_out",
"=",
"[",
"]",
"cond",
"=",
"self",
".",
"hass",
".",
"data",
"[",
"DATA_CONDITION",
"]",
"if",
"not",
"self",
".",
"_data",
".",
... | [
173,
4
] | [
200,
25
] | python | en | ['en', 'ga', 'en'] | True |
BrWeather.unique_id | (self) | Return the unique id. | Return the unique id. | def unique_id(self):
"""Return the unique id."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
203,
4
] | [
205,
30
] | python | en | ['en', 'la', 'en'] | True |
test_binary_sensor_async_setup_entry | (hass, aioclient_mock) | Test binary sensor setup. | Test binary sensor setup. | async def test_binary_sensor_async_setup_entry(hass, aioclient_mock):
"""Test binary sensor setup."""
aioclient_mock.get(
TEST_SYSTEM_URL,
text=TEST_SYSTEM_DATA,
)
aioclient_mock.get(
TEST_SET_URL,
text=TEST_SET_RESPONSE,
)
await add_mock_config(hass)
regist... | [
"async",
"def",
"test_binary_sensor_async_setup_entry",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"TEST_SYSTEM_URL",
",",
"text",
"=",
"TEST_SYSTEM_DATA",
",",
")",
"aioclient_mock",
".",
"get",
"(",
"TEST_SET_URL",
",",
"tex... | [
13,
0
] | [
68,
55
] | python | en | ['en', 'bs', 'en'] | True |
test_recent_items_intent | (hass, sl_setup) | Test recent items. | Test recent items. | async def test_recent_items_intent(hass, sl_setup):
"""Test recent items."""
await intent.async_handle(
hass, "test", "HassShoppingListAddItem", {"item": {"value": "beer"}}
)
await intent.async_handle(
hass, "test", "HassShoppingListAddItem", {"item": {"value": "wine"}}
)
await i... | [
"async",
"def",
"test_recent_items_intent",
"(",
"hass",
",",
"sl_setup",
")",
":",
"await",
"intent",
".",
"async_handle",
"(",
"hass",
",",
"\"test\"",
",",
"\"HassShoppingListAddItem\"",
",",
"{",
"\"item\"",
":",
"{",
"\"value\"",
":",
"\"beer\"",
"}",
"}"... | [
4,
0
] | [
21,
5
] | python | en | ['en', 'en', 'en'] | True |
DevoloDeviceEntity.__init__ | (self, homecontrol, device_instance, element_uid) | Initialize a devolo device entity. | Initialize a devolo device entity. | def __init__(self, homecontrol, device_instance, element_uid):
"""Initialize a devolo device entity."""
self._device_instance = device_instance
self._unique_id = element_uid
self._homecontrol = homecontrol
self._name = device_instance.settings_property["general_device_settings"].... | [
"def",
"__init__",
"(",
"self",
",",
"homecontrol",
",",
"device_instance",
",",
"element_uid",
")",
":",
"self",
".",
"_device_instance",
"=",
"device_instance",
"self",
".",
"_unique_id",
"=",
"element_uid",
"self",
".",
"_homecontrol",
"=",
"homecontrol",
"se... | [
14,
4
] | [
33,
39
] | python | it | ['it', 'it', 'it'] | True |
DevoloDeviceEntity.async_added_to_hass | (self) | Call when entity is added to hass. | Call when entity is added to hass. | async def async_added_to_hass(self) -> None:
"""Call when entity is added to hass."""
self.subscriber = Subscriber(self._name, callback=self.sync_callback)
self._homecontrol.publisher.register(
self._device_instance.uid, self.subscriber, self.sync_callback
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"subscriber",
"=",
"Subscriber",
"(",
"self",
".",
"_name",
",",
"callback",
"=",
"self",
".",
"sync_callback",
")",
"self",
".",
"_homecontrol",
".",
"publisher",
"."... | [
35,
4
] | [
40,
9
] | python | en | ['en', 'en', 'en'] | True |
DevoloDeviceEntity.async_will_remove_from_hass | (self) | Call when entity is removed or disabled. | Call when entity is removed or disabled. | async def async_will_remove_from_hass(self) -> None:
"""Call when entity is removed or disabled."""
self._homecontrol.publisher.unregister(
self._device_instance.uid, self.subscriber
) | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_homecontrol",
".",
"publisher",
".",
"unregister",
"(",
"self",
".",
"_device_instance",
".",
"uid",
",",
"self",
".",
"subscriber",
")"
] | [
42,
4
] | [
46,
9
] | python | en | ['en', 'en', 'en'] | True |
DevoloDeviceEntity.unique_id | (self) | Return the unique ID of the entity. | Return the unique ID of the entity. | def unique_id(self):
"""Return the unique ID of the entity."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
49,
4
] | [
51,
30
] | python | en | ['en', 'en', 'en'] | True |
DevoloDeviceEntity.device_info | (self) | Return the device info. | Return the device info. | def device_info(self):
"""Return the device info."""
return {
"identifiers": {(DOMAIN, self._device_instance.uid)},
"name": self._name,
"manufacturer": self._brand,
"model": self._model,
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_device_instance",
".",
"uid",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"_name",
",",
"\"manufacturer\"",
":",
"self",
".",
"... | [
54,
4
] | [
61,
9
] | python | en | ['en', 'en', 'en'] | True |
DevoloDeviceEntity.entity_registry_enabled_default | (self) | Return if the entity should be enabled when first added to the entity registry. | Return if the entity should be enabled when first added to the entity registry. | def entity_registry_enabled_default(self) -> bool:
"""Return if the entity should be enabled when first added to the entity registry."""
return self._enabled_default | [
"def",
"entity_registry_enabled_default",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_enabled_default"
] | [
64,
4
] | [
66,
36
] | python | en | ['en', 'en', 'en'] | True |
DevoloDeviceEntity.should_poll | (self) | Return the polling state. | Return the polling state. | def should_poll(self):
"""Return the polling state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
69,
4
] | [
71,
20
] | python | en | ['en', 'en', 'en'] | True |
DevoloDeviceEntity.name | (self) | Return the display name of this entity. | Return the display name of this entity. | def name(self):
"""Return the display name of this entity."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
74,
4
] | [
76,
25
] | python | en | ['en', 'en', 'en'] | True |
DevoloDeviceEntity.available | (self) | Return the online state. | Return the online state. | def available(self) -> bool:
"""Return the online state."""
return self._available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_available"
] | [
79,
4
] | [
81,
30
] | python | en | ['en', 'en', 'en'] | True |
DevoloDeviceEntity._sync | (self, message) | Update the state. | Update the state. | def _sync(self, message):
"""Update the state."""
if message[0] == self._unique_id:
self._value = message[1]
else:
self._generic_message(message)
self.schedule_update_ha_state() | [
"def",
"_sync",
"(",
"self",
",",
"message",
")",
":",
"if",
"message",
"[",
"0",
"]",
"==",
"self",
".",
"_unique_id",
":",
"self",
".",
"_value",
"=",
"message",
"[",
"1",
"]",
"else",
":",
"self",
".",
"_generic_message",
"(",
"message",
")",
"s... | [
83,
4
] | [
89,
39
] | python | en | ['en', 'en', 'en'] | True |
DevoloDeviceEntity._generic_message | (self, message) | Handle generic messages. | Handle generic messages. | def _generic_message(self, message):
"""Handle generic messages."""
if len(message) == 3 and message[2] == "battery_level":
self._value = message[1]
elif len(message) == 3 and message[2] == "status":
# Maybe the API wants to tell us, that the device went on- or offline.
... | [
"def",
"_generic_message",
"(",
"self",
",",
"message",
")",
":",
"if",
"len",
"(",
"message",
")",
"==",
"3",
"and",
"message",
"[",
"2",
"]",
"==",
"\"battery_level\"",
":",
"self",
".",
"_value",
"=",
"message",
"[",
"1",
"]",
"elif",
"len",
"(",
... | [
91,
4
] | [
99,
67
] | python | en | ['nl', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) | Set up the sensor config entry. | Set up the sensor config entry. | async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) -> None:
"""Set up the sensor config entry."""
controller_data = get_controller_data(hass, entry)
async_add_entities(
[
VeraSwitch(device, control... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"Callable",
"[",
"[",
"List",
"[",
"Entity",
"]",
",",
"bool",
"]",
",",
"None",
"]",
",",
")",
"->",
"None",
":",
... | [
19,
0
] | [
31,
5
] | python | en | ['en', 'pt', 'en'] | True |
VeraSwitch.__init__ | (
self, vera_device: veraApi.VeraSwitch, controller_data: ControllerData
) | Initialize the Vera device. | Initialize the Vera device. | def __init__(
self, vera_device: veraApi.VeraSwitch, controller_data: ControllerData
):
"""Initialize the Vera device."""
self._state = False
VeraDevice.__init__(self, vera_device, controller_data)
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id) | [
"def",
"__init__",
"(",
"self",
",",
"vera_device",
":",
"veraApi",
".",
"VeraSwitch",
",",
"controller_data",
":",
"ControllerData",
")",
":",
"self",
".",
"_state",
"=",
"False",
"VeraDevice",
".",
"__init__",
"(",
"self",
",",
"vera_device",
",",
"control... | [
37,
4
] | [
43,
62
] | python | en | ['en', 'en', 'en'] | True |
VeraSwitch.turn_on | (self, **kwargs: Any) | Turn device on. | Turn device on. | def turn_on(self, **kwargs: Any) -> None:
"""Turn device on."""
self.vera_device.switch_on()
self._state = True
self.schedule_update_ha_state() | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"self",
".",
"vera_device",
".",
"switch_on",
"(",
")",
"self",
".",
"_state",
"=",
"True",
"self",
".",
"schedule_update_ha_state",
"(",
")"
] | [
45,
4
] | [
49,
39
] | python | en | ['es', 'en', 'en'] | True |
VeraSwitch.turn_off | (self, **kwargs: Any) | Turn device off. | Turn device off. | def turn_off(self, **kwargs: Any) -> None:
"""Turn device off."""
self.vera_device.switch_off()
self._state = False
self.schedule_update_ha_state() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"self",
".",
"vera_device",
".",
"switch_off",
"(",
")",
"self",
".",
"_state",
"=",
"False",
"self",
".",
"schedule_update_ha_state",
"(",
")"
] | [
51,
4
] | [
55,
39
] | python | en | ['en', 'en', 'en'] | True |
VeraSwitch.current_power_w | (self) | Return the current power usage in W. | Return the current power usage in W. | def current_power_w(self) -> Optional[float]:
"""Return the current power usage in W."""
power = self.vera_device.power
if power:
return convert(power, float, 0.0) | [
"def",
"current_power_w",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"power",
"=",
"self",
".",
"vera_device",
".",
"power",
"if",
"power",
":",
"return",
"convert",
"(",
"power",
",",
"float",
",",
"0.0",
")"
] | [
58,
4
] | [
62,
45
] | python | en | ['en', 'en', 'en'] | True |
VeraSwitch.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self) -> bool:
"""Return true if device is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_state"
] | [
65,
4
] | [
67,
26
] | python | en | ['en', 'fy', 'en'] | True |
VeraSwitch.update | (self) | Update device state. | Update device state. | def update(self) -> None:
"""Update device state."""
self._state = self.vera_device.is_switched_on() | [
"def",
"update",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_state",
"=",
"self",
".",
"vera_device",
".",
"is_switched_on",
"(",
")"
] | [
69,
4
] | [
71,
55
] | python | en | ['fr', 'en', 'en'] | True |
list_schedules | () | List the schedules in the cluster.
Returns:
None.
| List the schedules in the cluster. | def list_schedules():
"""List the schedules in the cluster.
Returns:
None.
"""
name_to_schedule_details = redis_controller.get_name_to_schedule_details()
return list(name_to_schedule_details.values()) | [
"def",
"list_schedules",
"(",
")",
":",
"name_to_schedule_details",
"=",
"redis_controller",
".",
"get_name_to_schedule_details",
"(",
")",
"return",
"list",
"(",
"name_to_schedule_details",
".",
"values",
"(",
")",
")"
] | [
22,
0
] | [
30,
50
] | python | en | ['en', 'en', 'en'] | True |
get_schedule | (schedule_name: str) | Get the schedule with schedule_name.
Returns:
None.
| Get the schedule with schedule_name. | def get_schedule(schedule_name: str):
"""Get the schedule with schedule_name.
Returns:
None.
"""
schedule_details = redis_controller.get_schedule_details(schedule_name=schedule_name)
return schedule_details | [
"def",
"get_schedule",
"(",
"schedule_name",
":",
"str",
")",
":",
"schedule_details",
"=",
"redis_controller",
".",
"get_schedule_details",
"(",
"schedule_name",
"=",
"schedule_name",
")",
"return",
"schedule_details"
] | [
35,
0
] | [
43,
27
] | python | en | ['en', 'en', 'en'] | True |
create_schedule | (**kwargs) | Create a schedule.
Returns:
None.
| Create a schedule. | def create_schedule(**kwargs):
"""Create a schedule.
Returns:
None.
"""
schedule_details = kwargs["json_dict"]
redis_controller.set_schedule_details(
schedule_name=schedule_details["name"],
schedule_details=schedule_details
)
# Build individual jobs
for job_na... | [
"def",
"create_schedule",
"(",
"*",
"*",
"kwargs",
")",
":",
"schedule_details",
"=",
"kwargs",
"[",
"\"json_dict\"",
"]",
"redis_controller",
".",
"set_schedule_details",
"(",
"schedule_name",
"=",
"schedule_details",
"[",
"\"name\"",
"]",
",",
"schedule_details",
... | [
48,
0
] | [
69,
13
] | python | en | ['en', 'co', 'en'] | True |
delete_schedule | (schedule_name: str) | Delete a schedule.
Returns:
None.
| Delete a schedule. | def delete_schedule(schedule_name: str):
"""Delete a schedule.
Returns:
None.
"""
schedule_details = redis_controller.get_schedule_details(schedule_name=schedule_name)
for job_name in schedule_details["job_names"]:
redis_controller.remove_pending_job_ticket(job_name=job_name)
... | [
"def",
"delete_schedule",
"(",
"schedule_name",
":",
"str",
")",
":",
"schedule_details",
"=",
"redis_controller",
".",
"get_schedule_details",
"(",
"schedule_name",
"=",
"schedule_name",
")",
"for",
"job_name",
"in",
"schedule_details",
"[",
"\"job_names\"",
"]",
"... | [
74,
0
] | [
86,
13
] | python | co | ['de', 'co', 'en'] | False |
stop_schedule | (schedule_name: str) | Stop a schedule.
Returns:
None.
| Stop a schedule. | def stop_schedule(schedule_name: str):
"""Stop a schedule.
Returns:
None.
"""
schedule_details = redis_controller.get_schedule_details(schedule_name=schedule_name)
for job_name in schedule_details["job_names"]:
# FIXME: use schedule id to check
redis_controller.remove_pendi... | [
"def",
"stop_schedule",
"(",
"schedule_name",
":",
"str",
")",
":",
"schedule_details",
"=",
"redis_controller",
".",
"get_schedule_details",
"(",
"schedule_name",
"=",
"schedule_name",
")",
"for",
"job_name",
"in",
"schedule_details",
"[",
"\"job_names\"",
"]",
":"... | [
91,
0
] | [
103,
13
] | python | en | ['en', 'en', 'en'] | True |
entropy | (p) | Compute the entropy of a probability distribution | Compute the entropy of a probability distribution | def entropy(p):
""" Compute the entropy of a probability distribution """
plogp = p * torch.log(p)
plogp[p == 0] = 0
return -plogp.sum(dim=-1) | [
"def",
"entropy",
"(",
"p",
")",
":",
"plogp",
"=",
"p",
"*",
"torch",
".",
"log",
"(",
"p",
")",
"plogp",
"[",
"p",
"==",
"0",
"]",
"=",
"0",
"return",
"-",
"plogp",
".",
"sum",
"(",
"dim",
"=",
"-",
"1",
")"
] | [
50,
0
] | [
54,
29
] | python | en | ['en', 'en', 'en'] | True |
print_2d_tensor | (tensor) | Print a 2D tensor | Print a 2D tensor | def print_2d_tensor(tensor):
""" Print a 2D tensor """
logger.info("lv, h >\t" + "\t".join(f"{x + 1}" for x in range(len(tensor))))
for row in range(len(tensor)):
if tensor.dtype != torch.long:
logger.info(f"layer {row + 1}:\t" + "\t".join(f"{x:.5f}" for x in tensor[row].cpu().data))
... | [
"def",
"print_2d_tensor",
"(",
"tensor",
")",
":",
"logger",
".",
"info",
"(",
"\"lv, h >\\t\"",
"+",
"\"\\t\"",
".",
"join",
"(",
"f\"{x + 1}\"",
"for",
"x",
"in",
"range",
"(",
"len",
"(",
"tensor",
")",
")",
")",
")",
"for",
"row",
"in",
"range",
... | [
57,
0
] | [
64,
100
] | python | ca | ['en', 'ca', 'hi'] | False |
compute_heads_importance | (
args, model, eval_dataloader, compute_entropy=True, compute_importance=True, head_mask=None, actually_pruned=False
) | This method shows how to compute:
- head attention entropy
- head importance scores according to http://arxiv.org/abs/1905.10650
| This method shows how to compute:
- head attention entropy
- head importance scores according to http://arxiv.org/abs/1905.10650
| def compute_heads_importance(
args, model, eval_dataloader, compute_entropy=True, compute_importance=True, head_mask=None, actually_pruned=False
):
"""This method shows how to compute:
- head attention entropy
- head importance scores according to http://arxiv.org/abs/1905.10650
"""
# Prepare ou... | [
"def",
"compute_heads_importance",
"(",
"args",
",",
"model",
",",
"eval_dataloader",
",",
"compute_entropy",
"=",
"True",
",",
"compute_importance",
"=",
"True",
",",
"head_mask",
"=",
"None",
",",
"actually_pruned",
"=",
"False",
")",
":",
"# Prepare our tensors... | [
67,
0
] | [
150,
55
] | python | en | ['en', 'en', 'en'] | True |
mask_heads | (args, model, eval_dataloader) | This method shows how to mask head (set some heads to zero), to test the effect on the network,
based on the head importance scores, as described in Michel et al. (http://arxiv.org/abs/1905.10650)
| This method shows how to mask head (set some heads to zero), to test the effect on the network,
based on the head importance scores, as described in Michel et al. (http://arxiv.org/abs/1905.10650)
| def mask_heads(args, model, eval_dataloader):
"""This method shows how to mask head (set some heads to zero), to test the effect on the network,
based on the head importance scores, as described in Michel et al. (http://arxiv.org/abs/1905.10650)
"""
_, head_importance, preds, labels = compute_heads_impo... | [
"def",
"mask_heads",
"(",
"args",
",",
"model",
",",
"eval_dataloader",
")",
":",
"_",
",",
"head_importance",
",",
"preds",
",",
"labels",
"=",
"compute_heads_importance",
"(",
"args",
",",
"model",
",",
"eval_dataloader",
",",
"compute_entropy",
"=",
"False"... | [
153,
0
] | [
201,
20
] | python | en | ['en', 'en', 'en'] | True |
prune_heads | (args, model, eval_dataloader, head_mask) | This method shows how to prune head (remove heads weights) based on
the head importance scores as described in Michel et al. (http://arxiv.org/abs/1905.10650)
| This method shows how to prune head (remove heads weights) based on
the head importance scores as described in Michel et al. (http://arxiv.org/abs/1905.10650)
| def prune_heads(args, model, eval_dataloader, head_mask):
"""This method shows how to prune head (remove heads weights) based on
the head importance scores as described in Michel et al. (http://arxiv.org/abs/1905.10650)
"""
# Try pruning and test time speedup
# Pruning is like masking but we actuall... | [
"def",
"prune_heads",
"(",
"args",
",",
"model",
",",
"eval_dataloader",
",",
"head_mask",
")",
":",
"# Try pruning and test time speedup",
"# Pruning is like masking but we actually remove the masked weights",
"before_time",
"=",
"datetime",
".",
"now",
"(",
")",
"_",
",... | [
204,
0
] | [
248,
115
] | python | en | ['en', 'en', 'en'] | True |
JsonCorpusReader.__init__ | (self, root, fileids=DOC_PATTERN, **kwargs) |
Initialize the corpus reader. Categorization arguments
(``cat_pattern``, ``cat_map``, and ``cat_file``) are passed to
the ``CategorizedCorpusReader`` constructor. The remaining
arguments are passed to the ``CorpusReader`` constructor.
|
Initialize the corpus reader. Categorization arguments
(``cat_pattern``, ``cat_map``, and ``cat_file``) are passed to
the ``CategorizedCorpusReader`` constructor. The remaining
arguments are passed to the ``CorpusReader`` constructor.
| def __init__(self, root, fileids=DOC_PATTERN, **kwargs):
"""
Initialize the corpus reader. Categorization arguments
(``cat_pattern``, ``cat_map``, and ``cat_file``) are passed to
the ``CategorizedCorpusReader`` constructor. The remaining
arguments are passed to the ``CorpusRead... | [
"def",
"__init__",
"(",
"self",
",",
"root",
",",
"fileids",
"=",
"DOC_PATTERN",
",",
"*",
"*",
"kwargs",
")",
":",
"CorpusReader",
".",
"__init__",
"(",
"self",
",",
"root",
",",
"fileids",
")"
] | [
15,
4
] | [
22,
50
] | python | en | ['en', 'error', 'th'] | False |
JsonCorpusReader.resolve | (self, fileids) |
Returns a list of fileids.
|
Returns a list of fileids.
| def resolve(self, fileids):
"""
Returns a list of fileids.
"""
return fileids | [
"def",
"resolve",
"(",
"self",
",",
"fileids",
")",
":",
"return",
"fileids"
] | [
24,
4
] | [
28,
22
] | python | en | ['en', 'error', 'th'] | False |
JsonCorpusReader.reviews | (self, fileids=None) |
Returns the complete text of the JSON document, closing the document
after we are done reading it and yielding it in a memory safe fashion.
|
Returns the complete text of the JSON document, closing the document
after we are done reading it and yielding it in a memory safe fashion.
| def reviews(self, fileids=None):
"""
Returns the complete text of the JSON document, closing the document
after we are done reading it and yielding it in a memory safe fashion.
"""
# Create a generator, loading one document into memory at a time.
for path, encoding in sel... | [
"def",
"reviews",
"(",
"self",
",",
"fileids",
"=",
"None",
")",
":",
"# Create a generator, loading one document into memory at a time.",
"for",
"path",
",",
"encoding",
"in",
"self",
".",
"abspaths",
"(",
"fileids",
",",
"include_encoding",
"=",
"True",
")",
":"... | [
30,
4
] | [
38,
34
] | python | en | ['en', 'error', 'th'] | False |
JsonCorpusReader.texts | (self) |
Returns the full review texts
|
Returns the full review texts
| def texts(self):
"""
Returns the full review texts
"""
for review in self.reviews():
yield review["reviewText"] | [
"def",
"texts",
"(",
"self",
")",
":",
"for",
"review",
"in",
"self",
".",
"reviews",
"(",
")",
":",
"yield",
"review",
"[",
"\"reviewText\"",
"]"
] | [
40,
4
] | [
45,
38
] | python | en | ['en', 'error', 'th'] | False |
JsonCorpusReader.scores | (self) |
Returns the review scores
|
Returns the review scores
| def scores(self):
"""
Returns the review scores
"""
for review in self.reviews():
yield review["overall"] | [
"def",
"scores",
"(",
"self",
")",
":",
"for",
"review",
"in",
"self",
".",
"reviews",
"(",
")",
":",
"yield",
"review",
"[",
"\"overall\"",
"]"
] | [
47,
4
] | [
52,
35
] | python | en | ['en', 'error', 'th'] | False |
JsonCorpusReader.ids | (self) |
Returns the review ids
|
Returns the review ids
| def ids(self):
"""
Returns the review ids
"""
for review in self.reviews():
yield review["unixReviewTime"] | [
"def",
"ids",
"(",
"self",
")",
":",
"for",
"review",
"in",
"self",
".",
"reviews",
"(",
")",
":",
"yield",
"review",
"[",
"\"unixReviewTime\"",
"]"
] | [
54,
4
] | [
59,
42
] | python | en | ['en', 'error', 'th'] | False |
JsonCorpusReader.ids_scores_texts | (self) |
Returns the review ids, scores & texts
|
Returns the review ids, scores & texts
| def ids_scores_texts(self):
"""
Returns the review ids, scores & texts
"""
for review in self.reviews():
yield (review["unixReviewTime"], review["overall"], review["reviewText"]) | [
"def",
"ids_scores_texts",
"(",
"self",
")",
":",
"for",
"review",
"in",
"self",
".",
"reviews",
"(",
")",
":",
"yield",
"(",
"review",
"[",
"\"unixReviewTime\"",
"]",
",",
"review",
"[",
"\"overall\"",
"]",
",",
"review",
"[",
"\"reviewText\"",
"]",
")"... | [
61,
4
] | [
66,
85
] | python | en | ['en', 'error', 'th'] | False |
JsonCorpusReader.sents | (self) |
Returns a generator of sentences.
|
Returns a generator of sentences.
| def sents(self):
"""
Returns a generator of sentences.
"""
for text in self.texts():
for sentence in nltk.sent_tokenize(text):
yield sentence | [
"def",
"sents",
"(",
"self",
")",
":",
"for",
"text",
"in",
"self",
".",
"texts",
"(",
")",
":",
"for",
"sentence",
"in",
"nltk",
".",
"sent_tokenize",
"(",
"text",
")",
":",
"yield",
"sentence"
] | [
68,
4
] | [
74,
30
] | python | en | ['en', 'error', 'th'] | False |
JsonCorpusReader.words | (self) |
Returns a generator of words.
|
Returns a generator of words.
| def words(self):
"""
Returns a generator of words.
"""
for sent in self.sents():
for word in nltk.wordpunct_tokenize(sent):
yield word | [
"def",
"words",
"(",
"self",
")",
":",
"for",
"sent",
"in",
"self",
".",
"sents",
"(",
")",
":",
"for",
"word",
"in",
"nltk",
".",
"wordpunct_tokenize",
"(",
"sent",
")",
":",
"yield",
"word"
] | [
76,
4
] | [
82,
26
] | python | en | ['en', 'error', 'th'] | False |
PickledAmazonReviewsReader.__init__ | (self, root, fileids=PKL_PATTERN, **kwargs) |
Initialize the corpus reader
|
Initialize the corpus reader
| def __init__(self, root, fileids=PKL_PATTERN, **kwargs):
"""
Initialize the corpus reader
"""
CorpusReader.__init__(self, root, fileids, **kwargs) | [
"def",
"__init__",
"(",
"self",
",",
"root",
",",
"fileids",
"=",
"PKL_PATTERN",
",",
"*",
"*",
"kwargs",
")",
":",
"CorpusReader",
".",
"__init__",
"(",
"self",
",",
"root",
",",
"fileids",
",",
"*",
"*",
"kwargs",
")"
] | [
91,
4
] | [
95,
60
] | python | en | ['en', 'error', 'th'] | False |
PickledAmazonReviewsReader.texts_scores | (self, fileids=None) |
Returns the document loaded from a pickled object for every file in
the corpus. Similar to the JsonCorpusReader, this uses a generator
to achieve memory safe iteration.
|
Returns the document loaded from a pickled object for every file in
the corpus. Similar to the JsonCorpusReader, this uses a generator
to achieve memory safe iteration.
| def texts_scores(self, fileids=None):
"""
Returns the document loaded from a pickled object for every file in
the corpus. Similar to the JsonCorpusReader, this uses a generator
to achieve memory safe iteration.
"""
# Create a generator, loading one document into memory at... | [
"def",
"texts_scores",
"(",
"self",
",",
"fileids",
"=",
"None",
")",
":",
"# Create a generator, loading one document into memory at a time.",
"for",
"path",
",",
"enc",
",",
"fileid",
"in",
"self",
".",
"abspaths",
"(",
"fileids",
",",
"True",
",",
"True",
")"... | [
97,
4
] | [
106,
36
] | python | en | ['en', 'error', 'th'] | False |
PickledAmazonReviewsReader.reviews | (self, fileids=None) |
Returns a generator of paragraphs where each paragraph is a list of
sentences, which is in turn a list of (token, tag) tuples.
|
Returns a generator of paragraphs where each paragraph is a list of
sentences, which is in turn a list of (token, tag) tuples.
| def reviews(self, fileids=None):
"""
Returns a generator of paragraphs where each paragraph is a list of
sentences, which is in turn a list of (token, tag) tuples.
"""
for text,score in self.texts_scores(fileids):
yield text | [
"def",
"reviews",
"(",
"self",
",",
"fileids",
"=",
"None",
")",
":",
"for",
"text",
",",
"score",
"in",
"self",
".",
"texts_scores",
"(",
"fileids",
")",
":",
"yield",
"text"
] | [
108,
4
] | [
114,
22
] | python | en | ['en', 'error', 'th'] | False |
PickledAmazonReviewsReader.scores | (self, fileids=None) |
Return the scores
|
Return the scores
| def scores(self, fileids=None):
"""
Return the scores
"""
for text,score in self.texts_scores(fileids):
yield score | [
"def",
"scores",
"(",
"self",
",",
"fileids",
"=",
"None",
")",
":",
"for",
"text",
",",
"score",
"in",
"self",
".",
"texts_scores",
"(",
"fileids",
")",
":",
"yield",
"score"
] | [
116,
4
] | [
121,
23
] | python | en | ['en', 'error', 'th'] | False |
PickledAmazonReviewsReader.sents | (self, fileids=None) |
Returns a generator of sentences where each sentence is a list of
(token, tag) tuples.
|
Returns a generator of sentences where each sentence is a list of
(token, tag) tuples.
| def sents(self, fileids=None):
"""
Returns a generator of sentences where each sentence is a list of
(token, tag) tuples.
"""
for review in self.reviews(fileids):
for sentence in review:
yield sentence | [
"def",
"sents",
"(",
"self",
",",
"fileids",
"=",
"None",
")",
":",
"for",
"review",
"in",
"self",
".",
"reviews",
"(",
"fileids",
")",
":",
"for",
"sentence",
"in",
"review",
":",
"yield",
"sentence"
] | [
123,
4
] | [
130,
30
] | python | en | ['en', 'error', 'th'] | False |
PickledAmazonReviewsReader.words | (self, fileids=None) |
Returns a generator of (token, tag) tuples.
|
Returns a generator of (token, tag) tuples.
| def words(self, fileids=None):
"""
Returns a generator of (token, tag) tuples.
"""
for token in self.tagged(fileids):
yield token[0] | [
"def",
"words",
"(",
"self",
",",
"fileids",
"=",
"None",
")",
":",
"for",
"token",
"in",
"self",
".",
"tagged",
"(",
"fileids",
")",
":",
"yield",
"token",
"[",
"0",
"]"
] | [
137,
4
] | [
142,
26
] | python | en | ['en', 'error', 'th'] | False |
start_vis | (source_path: str, force: str, **kwargs: dict) | Entrance of data pre-processing.
Generate index_name_conversion CSV file and summary file.
Expected File Structure:
-input_file_folder_path
--epoch_0 : Data of current epoch.
--holder_info.csv: Attributes of current epoch.
………………
--epoch_{epoch_num-1}
--manifest... | Entrance of data pre-processing. | def start_vis(source_path: str, force: str, **kwargs: dict):
"""Entrance of data pre-processing.
Generate index_name_conversion CSV file and summary file.
Expected File Structure:
-input_file_folder_path
--epoch_0 : Data of current epoch.
--holder_info.csv: Attributes of current ep... | [
"def",
"start_vis",
"(",
"source_path",
":",
"str",
",",
"force",
":",
"str",
",",
"*",
"*",
"kwargs",
":",
"dict",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"join",
"(",
"source_path",
",",
"\"manifest.y... | [
22,
0
] | [
80,
62
] | python | en | ['en', 'en', 'en'] | True |
str2bool | (force_type) | Convert the parameter "force" from string to bool.
Argsparse could not identify bool type automatically.
Manually conversion is compulsory.
Args:
force_type (str): The parameter input by user.
Returns:
bool: Converted parameter.
| Convert the parameter "force" from string to bool. | def str2bool(force_type) -> bool:
"""Convert the parameter "force" from string to bool.
Argsparse could not identify bool type automatically.
Manually conversion is compulsory.
Args:
force_type (str): The parameter input by user.
Returns:
bool: Converted parameter.
"""
if... | [
"def",
"str2bool",
"(",
"force_type",
")",
"->",
"bool",
":",
"if",
"force_type",
".",
"lower",
"(",
")",
"in",
"(",
"'yes'",
",",
"'true'",
",",
"'t'",
",",
"'y'",
",",
"'1'",
")",
":",
"return",
"True",
"elif",
"force_type",
".",
"lower",
"(",
")... | [
83,
0
] | [
99,
20
] | python | en | ['en', 'en', 'en'] | True |
_init_csv | (file_path: str, header: List[str]) | Clean and initiate summary csv file.
This summary file record cross-epoch data.
Args:
file_path (str): Path of the summary file.
header (List[str]): Expected header of summary file.
| Clean and initiate summary csv file. | def _init_csv(file_path: str, header: List[str]):
"""Clean and initiate summary csv file.
This summary file record cross-epoch data.
Args:
file_path (str): Path of the summary file.
header (List[str]): Expected header of summary file.
"""
if os.path.exists(file_path):
os.re... | [
"def",
"_init_csv",
"(",
"file_path",
":",
"str",
",",
"header",
":",
"List",
"[",
"str",
"]",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"file_path",
")",
":",
"os",
".",
"remove",
"(",
"file_path",
")",
"with",
"open",
"(",
"file_path... | [
102,
0
] | [
115,
28
] | python | en | ['en', 'en', 'en'] | True |
_summary_append | (
scenario: GlobalScenarios, input_path: str, header_list: List[str],
sum_dataframe: pd.DataFrame, epoch_index: int, output_path: str
) | Calculate summary info and generate corresponding csv file.
To accelerate, change each column into numpy.array.
Args:
scenario (GlobalScenarios): Current scenario.
input_path (str): Path of file needed to be summarized.
header_list (List[str]): List of columns needed to be summarized.
... | Calculate summary info and generate corresponding csv file. | def _summary_append(
scenario: GlobalScenarios, input_path: str, header_list: List[str],
sum_dataframe: pd.DataFrame, epoch_index: int, output_path: str
):
"""Calculate summary info and generate corresponding csv file.
To accelerate, change each column into numpy.array.
Args:
scenario (Glo... | [
"def",
"_summary_append",
"(",
"scenario",
":",
"GlobalScenarios",
",",
"input_path",
":",
"str",
",",
"header_list",
":",
"List",
"[",
"str",
"]",
",",
"sum_dataframe",
":",
"pd",
".",
"DataFrame",
",",
"epoch_index",
":",
"int",
",",
"output_path",
":",
... | [
118,
0
] | [
139,
62
] | python | en | ['en', 'en', 'en'] | True |
_generate_summary | (scenario: GlobalScenarios, source_path: str, prefix: str, epoch_num: int) | Generate summary info of current scenario.
Different scenario has different data features.
Each scenario should be treated respectively.
Args:
scenario (GlobalScenarios): Current scenario.
source_path (str): The root path of the dumped snapshots data for the corresponding experiment.
... | Generate summary info of current scenario. | def _generate_summary(scenario: GlobalScenarios, source_path: str, prefix: str, epoch_num: int):
"""Generate summary info of current scenario.
Different scenario has different data features.
Each scenario should be treated respectively.
Args:
scenario (GlobalScenarios): Current scenario.
... | [
"def",
"_generate_summary",
"(",
"scenario",
":",
"GlobalScenarios",
",",
"source_path",
":",
"str",
",",
"prefix",
":",
"str",
",",
"epoch_num",
":",
"int",
")",
":",
"ports_header",
"=",
"[",
"\"capacity\"",
",",
"\"empty\"",
",",
"\"full\"",
",",
"\"on_sh... | [
142,
0
] | [
197,
13
] | python | en | ['en', 'la', 'en'] | True |
_get_index_index_name_conversion | (scenario: GlobalScenarios, source_path: str, conversion_path: str) | Generate a CSV File which indicates the relationship between resource holder's index and name.
Args:
scenario (GlobalScenarios): Current scenario. Different scenario has different type of mapping file.
source_path (str): The root path of the dumped snapshots data for the corresponding experiment.
... | Generate a CSV File which indicates the relationship between resource holder's index and name. | def _get_index_index_name_conversion(scenario: GlobalScenarios, source_path: str, conversion_path: str):
""" Generate a CSV File which indicates the relationship between resource holder's index and name.
Args:
scenario (GlobalScenarios): Current scenario. Different scenario has different type of mappin... | [
"def",
"_get_index_index_name_conversion",
"(",
"scenario",
":",
"GlobalScenarios",
",",
"source_path",
":",
"str",
",",
"conversion_path",
":",
"str",
")",
":",
"conversion_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"source_path",
",",
"conversion_path",
... | [
200,
0
] | [
226,
87
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable
) | Record the async_add_entities function to add them later when received from Dynalite. | Record the async_add_entities function to add them later when received from Dynalite. | async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable
) -> None:
"""Record the async_add_entities function to add them later when received from Dynalite."""
async_setup_entry_base(
hass, config_entry, async_add_entities, "switch", DynaliteSwitch
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"Callable",
")",
"->",
"None",
":",
"async_setup_entry_base",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities"... | [
10,
0
] | [
17,
5
] | python | en | ['en', 'en', 'en'] | True |
DynaliteSwitch.is_on | (self) | Return true if switch is on. | Return true if switch is on. | def is_on(self) -> bool:
"""Return true if switch is on."""
return self._device.is_on | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_device",
".",
"is_on"
] | [
24,
4
] | [
26,
33
] | python | en | ['en', 'fy', 'en'] | True |
DynaliteSwitch.async_turn_on | (self, **kwargs) | Turn the switch on. | Turn the switch on. | async def async_turn_on(self, **kwargs) -> None:
"""Turn the switch on."""
await self._device.async_turn_on() | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"await",
"self",
".",
"_device",
".",
"async_turn_on",
"(",
")"
] | [
28,
4
] | [
30,
42
] | python | en | ['en', 'en', 'en'] | True |
DynaliteSwitch.async_turn_off | (self, **kwargs) | Turn the switch off. | Turn the switch off. | async def async_turn_off(self, **kwargs) -> None:
"""Turn the switch off."""
await self._device.async_turn_off() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"await",
"self",
".",
"_device",
".",
"async_turn_off",
"(",
")"
] | [
32,
4
] | [
34,
43
] | python | en | ['en', 'en', 'en'] | True |
compute_accuracy | (output, target, topk=(1,)) | Computes the accuracy over the k top predictions for the specified values of k | Computes the accuracy over the k top predictions for the specified values of k | def compute_accuracy(output, target, topk=(1,)):
"""Computes the accuracy over the k top predictions for the specified values of k"""
with torch.no_grad():
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = p... | [
"def",
"compute_accuracy",
"(",
"output",
",",
"target",
",",
"topk",
"=",
"(",
"1",
",",
")",
")",
":",
"with",
"torch",
".",
"no_grad",
"(",
")",
":",
"maxk",
"=",
"max",
"(",
"topk",
")",
"batch_size",
"=",
"target",
".",
"size",
"(",
"0",
")"... | [
18,
0
] | [
32,
18
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up Blinkstick device specified by serial number. | Set up Blinkstick device specified by serial number. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up Blinkstick device specified by serial number."""
name = config[CONF_NAME]
serial = config[CONF_SERIAL]
stick = blinkstick.find_by_serial(serial)
add_entities([BlinkStickLight(stick, name)], True) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"name",
"=",
"config",
"[",
"CONF_NAME",
"]",
"serial",
"=",
"config",
"[",
"CONF_SERIAL",
"]",
"stick",
"=",
"blinkstick",
".",
"find_b... | [
30,
0
] | [
38,
54
] | python | en | ['en', 'en', 'en'] | True |
BlinkStickLight.__init__ | (self, stick, name) | Initialize the light. | Initialize the light. | def __init__(self, stick, name):
"""Initialize the light."""
self._stick = stick
self._name = name
self._serial = stick.get_serial()
self._hs_color = None
self._brightness = None | [
"def",
"__init__",
"(",
"self",
",",
"stick",
",",
"name",
")",
":",
"self",
".",
"_stick",
"=",
"stick",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_serial",
"=",
"stick",
".",
"get_serial",
"(",
")",
"self",
".",
"_hs_color",
"=",
"None",
"... | [
44,
4
] | [
50,
31
] | python | en | ['en', 'en', 'en'] | True |
BlinkStickLight.name | (self) | Return the name of the light. | Return the name of the light. | def name(self):
"""Return the name of the light."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
53,
4
] | [
55,
25
] | python | en | ['en', 'en', 'en'] | True |
BlinkStickLight.brightness | (self) | Read back the brightness of the light. | Read back the brightness of the light. | def brightness(self):
"""Read back the brightness of the light."""
return self._brightness | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"self",
".",
"_brightness"
] | [
58,
4
] | [
60,
31
] | python | en | ['en', 'en', 'en'] | True |
BlinkStickLight.hs_color | (self) | Read back the color of the light. | Read back the color of the light. | def hs_color(self):
"""Read back the color of the light."""
return self._hs_color | [
"def",
"hs_color",
"(",
"self",
")",
":",
"return",
"self",
".",
"_hs_color"
] | [
63,
4
] | [
65,
29
] | python | en | ['en', 'en', 'en'] | True |
BlinkStickLight.is_on | (self) | Return True if entity is on. | Return True if entity is on. | def is_on(self):
"""Return True if entity is on."""
return self._brightness > 0 | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_brightness",
">",
"0"
] | [
68,
4
] | [
70,
35
] | python | en | ['en', 'cy', 'en'] | True |
BlinkStickLight.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return SUPPORT_BLINKSTICK | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_BLINKSTICK"
] | [
73,
4
] | [
75,
33
] | python | en | ['da', 'en', 'en'] | True |
BlinkStickLight.update | (self) | Read back the device state. | Read back the device state. | def update(self):
"""Read back the device state."""
rgb_color = self._stick.get_color()
hsv = color_util.color_RGB_to_hsv(*rgb_color)
self._hs_color = hsv[:2]
self._brightness = hsv[2] | [
"def",
"update",
"(",
"self",
")",
":",
"rgb_color",
"=",
"self",
".",
"_stick",
".",
"get_color",
"(",
")",
"hsv",
"=",
"color_util",
".",
"color_RGB_to_hsv",
"(",
"*",
"rgb_color",
")",
"self",
".",
"_hs_color",
"=",
"hsv",
"[",
":",
"2",
"]",
"sel... | [
77,
4
] | [
82,
33
] | 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.