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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
loguniform | (low, high, random_state) |
low: an float that represent an lower bound
high: an float that represent an upper bound
random_state: an object of numpy.random.RandomState
|
low: an float that represent an lower bound
high: an float that represent an upper bound
random_state: an object of numpy.random.RandomState
| def loguniform(low, high, random_state):
'''
low: an float that represent an lower bound
high: an float that represent an upper bound
random_state: an object of numpy.random.RandomState
'''
assert low > 0, 'Lower bound must be positive'
return np.exp(uniform(np.log(low), np.log(high), random... | [
"def",
"loguniform",
"(",
"low",
",",
"high",
",",
"random_state",
")",
":",
"assert",
"low",
">",
"0",
",",
"'Lower bound must be positive'",
"return",
"np",
".",
"exp",
"(",
"uniform",
"(",
"np",
".",
"log",
"(",
"low",
")",
",",
"np",
".",
"log",
... | [
48,
0
] | [
55,
67
] | python | en | ['en', 'error', 'th'] | False |
qloguniform | (low, high, q, random_state) |
low: an float that represent an lower bound
high: an float that represent an upper bound
q: sample step
random_state: an object of numpy.random.RandomState
|
low: an float that represent an lower bound
high: an float that represent an upper bound
q: sample step
random_state: an object of numpy.random.RandomState
| def qloguniform(low, high, q, random_state):
'''
low: an float that represent an lower bound
high: an float that represent an upper bound
q: sample step
random_state: an object of numpy.random.RandomState
'''
return np.clip(np.round(loguniform(low, high, random_state) / q) * q, low, high) | [
"def",
"qloguniform",
"(",
"low",
",",
"high",
",",
"q",
",",
"random_state",
")",
":",
"return",
"np",
".",
"clip",
"(",
"np",
".",
"round",
"(",
"loguniform",
"(",
"low",
",",
"high",
",",
"random_state",
")",
"/",
"q",
")",
"*",
"q",
",",
"low... | [
58,
0
] | [
65,
84
] | python | en | ['en', 'error', 'th'] | False |
normal | (mu, sigma, random_state) |
The probability density function of the normal distribution,
first derived by De Moivre and 200 years later by both Gauss and Laplace independently.
mu: float or array_like of floats
Mean (“centre”) of the distribution.
sigma: float or array_like of floats
Standard deviation (spread ... |
The probability density function of the normal distribution,
first derived by De Moivre and 200 years later by both Gauss and Laplace independently.
mu: float or array_like of floats
Mean (“centre”) of the distribution.
sigma: float or array_like of floats
Standard deviation (spread ... | def normal(mu, sigma, random_state):
'''
The probability density function of the normal distribution,
first derived by De Moivre and 200 years later by both Gauss and Laplace independently.
mu: float or array_like of floats
Mean (“centre”) of the distribution.
sigma: float or array_like of f... | [
"def",
"normal",
"(",
"mu",
",",
"sigma",
",",
"random_state",
")",
":",
"return",
"random_state",
".",
"normal",
"(",
"mu",
",",
"sigma",
")"
] | [
68,
0
] | [
78,
41
] | python | en | ['en', 'error', 'th'] | False |
qnormal | (mu, sigma, q, random_state) |
mu: float or array_like of floats
sigma: float or array_like of floats
q: sample step
random_state: an object of numpy.random.RandomState
|
mu: float or array_like of floats
sigma: float or array_like of floats
q: sample step
random_state: an object of numpy.random.RandomState
| def qnormal(mu, sigma, q, random_state):
'''
mu: float or array_like of floats
sigma: float or array_like of floats
q: sample step
random_state: an object of numpy.random.RandomState
'''
return np.round(normal(mu, sigma, random_state) / q) * q | [
"def",
"qnormal",
"(",
"mu",
",",
"sigma",
",",
"q",
",",
"random_state",
")",
":",
"return",
"np",
".",
"round",
"(",
"normal",
"(",
"mu",
",",
"sigma",
",",
"random_state",
")",
"/",
"q",
")",
"*",
"q"
] | [
81,
0
] | [
88,
60
] | python | en | ['en', 'error', 'th'] | False |
lognormal | (mu, sigma, random_state) |
mu: float or array_like of floats
sigma: float or array_like of floats
random_state: an object of numpy.random.RandomState
|
mu: float or array_like of floats
sigma: float or array_like of floats
random_state: an object of numpy.random.RandomState
| def lognormal(mu, sigma, random_state):
'''
mu: float or array_like of floats
sigma: float or array_like of floats
random_state: an object of numpy.random.RandomState
'''
return np.exp(normal(mu, sigma, random_state)) | [
"def",
"lognormal",
"(",
"mu",
",",
"sigma",
",",
"random_state",
")",
":",
"return",
"np",
".",
"exp",
"(",
"normal",
"(",
"mu",
",",
"sigma",
",",
"random_state",
")",
")"
] | [
91,
0
] | [
97,
50
] | python | en | ['en', 'error', 'th'] | False |
qlognormal | (mu, sigma, q, random_state) |
mu: float or array_like of floats
sigma: float or array_like of floats
q: sample step
random_state: an object of numpy.random.RandomState
|
mu: float or array_like of floats
sigma: float or array_like of floats
q: sample step
random_state: an object of numpy.random.RandomState
| def qlognormal(mu, sigma, q, random_state):
'''
mu: float or array_like of floats
sigma: float or array_like of floats
q: sample step
random_state: an object of numpy.random.RandomState
'''
return np.round(lognormal(mu, sigma, random_state) / q) * q | [
"def",
"qlognormal",
"(",
"mu",
",",
"sigma",
",",
"q",
",",
"random_state",
")",
":",
"return",
"np",
".",
"round",
"(",
"lognormal",
"(",
"mu",
",",
"sigma",
",",
"random_state",
")",
"/",
"q",
")",
"*",
"q"
] | [
100,
0
] | [
107,
63
] | python | en | ['en', 'error', 'th'] | False |
NetatmoDataHandler.__init__ | (self, hass: HomeAssistant, entry: ConfigEntry) | Initialize self. | Initialize self. | def __init__(self, hass: HomeAssistant, entry: ConfigEntry):
"""Initialize self."""
self.hass = hass
self._auth = hass.data[DOMAIN][entry.entry_id][AUTH]
self.listeners: List[CALLBACK_TYPE] = []
self._data_classes: Dict = {}
self.data = {}
self._queue: Deque = deq... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"_auth",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
... | [
53,
4
] | [
61,
35
] | python | en | ['en', 'co', 'en'] | False |
NetatmoDataHandler.async_setup | (self) | Set up the Netatmo data handler. | Set up the Netatmo data handler. | async def async_setup(self):
"""Set up the Netatmo data handler."""
async_track_time_interval(
self.hass, self.async_update, timedelta(seconds=SCAN_INTERVAL)
)
self.listeners.append(
async_dispatcher_connect(
self.hass,
f"signal-{... | [
"async",
"def",
"async_setup",
"(",
"self",
")",
":",
"async_track_time_interval",
"(",
"self",
".",
"hass",
",",
"self",
".",
"async_update",
",",
"timedelta",
"(",
"seconds",
"=",
"SCAN_INTERVAL",
")",
")",
"self",
".",
"listeners",
".",
"append",
"(",
"... | [
63,
4
] | [
76,
9
] | python | en | ['en', 'no', 'en'] | True |
NetatmoDataHandler.async_update | (self, event_time) |
Update device.
We do up to BATCH_SIZE calls in one update in order
to minimize the calls on the api service.
|
Update device. | async def async_update(self, event_time):
"""
Update device.
We do up to BATCH_SIZE calls in one update in order
to minimize the calls on the api service.
"""
for data_class in islice(self._queue, 0, BATCH_SIZE):
if data_class[NEXT_SCAN] > time():
... | [
"async",
"def",
"async_update",
"(",
"self",
",",
"event_time",
")",
":",
"for",
"data_class",
"in",
"islice",
"(",
"self",
".",
"_queue",
",",
"0",
",",
"BATCH_SIZE",
")",
":",
"if",
"data_class",
"[",
"NEXT_SCAN",
"]",
">",
"time",
"(",
")",
":",
"... | [
78,
4
] | [
96,
38
] | python | en | ['en', 'error', 'th'] | False |
NetatmoDataHandler.async_cleanup | (self) | Clean up the Netatmo data handler. | Clean up the Netatmo data handler. | async def async_cleanup(self):
"""Clean up the Netatmo data handler."""
for listener in self.listeners:
listener() | [
"async",
"def",
"async_cleanup",
"(",
"self",
")",
":",
"for",
"listener",
"in",
"self",
".",
"listeners",
":",
"listener",
"(",
")"
] | [
98,
4
] | [
101,
22
] | python | en | ['en', 'no', 'en'] | True |
NetatmoDataHandler.handle_event | (self, event) | Handle webhook events. | Handle webhook events. | async def handle_event(self, event):
"""Handle webhook events."""
if event["data"]["push_type"] == "webhook_activation":
_LOGGER.info("%s webhook successfully registered", MANUFACTURER)
self._webhook = True
elif event["data"]["push_type"] == "NACamera-connection":
... | [
"async",
"def",
"handle_event",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
"[",
"\"data\"",
"]",
"[",
"\"push_type\"",
"]",
"==",
"\"webhook_activation\"",
":",
"_LOGGER",
".",
"info",
"(",
"\"%s webhook successfully registered\"",
",",
"MANUFACTURER",
... | [
103,
4
] | [
111,
74
] | python | en | ['eu', 'xh', 'en'] | False |
NetatmoDataHandler.async_fetch_data | (self, data_class, data_class_entry, **kwargs) | Fetch data and notify. | Fetch data and notify. | async def async_fetch_data(self, data_class, data_class_entry, **kwargs):
"""Fetch data and notify."""
try:
self.data[data_class_entry] = await self.hass.async_add_executor_job(
partial(data_class, **kwargs),
self._auth,
)
for update_ca... | [
"async",
"def",
"async_fetch_data",
"(",
"self",
",",
"data_class",
",",
"data_class_entry",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"data",
"[",
"data_class_entry",
"]",
"=",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
... | [
113,
4
] | [
127,
30
] | python | en | ['en', 'en', 'en'] | True |
NetatmoDataHandler.register_data_class | (
self, data_class_name, data_class_entry, update_callback, **kwargs
) | Register data class. | Register data class. | async def register_data_class(
self, data_class_name, data_class_entry, update_callback, **kwargs
):
"""Register data class."""
if data_class_entry in self._data_classes:
self._data_classes[data_class_entry]["subscriptions"].append(
update_callback
)
... | [
"async",
"def",
"register_data_class",
"(",
"self",
",",
"data_class_name",
",",
"data_class_entry",
",",
"update_callback",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"data_class_entry",
"in",
"self",
".",
"_data_classes",
":",
"self",
".",
"_data_classes",
"[",
... | [
129,
4
] | [
153,
62
] | python | de | ['de', 'lb', 'en'] | False |
NetatmoDataHandler.unregister_data_class | (self, data_class_entry, update_callback) | Unregister data class. | Unregister data class. | async def unregister_data_class(self, data_class_entry, update_callback):
"""Unregister data class."""
if update_callback not in self._data_classes[data_class_entry]["subscriptions"]:
return
self._data_classes[data_class_entry]["subscriptions"].remove(update_callback)
if no... | [
"async",
"def",
"unregister_data_class",
"(",
"self",
",",
"data_class_entry",
",",
"update_callback",
")",
":",
"if",
"update_callback",
"not",
"in",
"self",
".",
"_data_classes",
"[",
"data_class_entry",
"]",
"[",
"\"subscriptions\"",
"]",
":",
"return",
"self",... | [
155,
4
] | [
165,
68
] | python | de | ['de', 'it', 'en'] | False |
NetatmoDataHandler.webhook | (self) | Return the webhook state. | Return the webhook state. | def webhook(self) -> bool:
"""Return the webhook state."""
return self._webhook | [
"def",
"webhook",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_webhook"
] | [
168,
4
] | [
170,
28
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
) | Set up MelCloud device climate based on config_entry. | Set up MelCloud device climate based on config_entry. | async def async_setup_entry(
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
):
"""Set up MelCloud device climate based on config_entry."""
mel_devices = hass.data[DOMAIN][entry.entry_id]
async_add_entities(
[
AtwWaterHeater(mel_device, mel_device.device)
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
")",
":",
"mel_devices",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"async_add_entit... | [
23,
0
] | [
34,
5
] | python | en | ['en', 'en', 'en'] | True |
AtwWaterHeater.__init__ | (self, api: MelCloudDevice, device: AtwDevice) | Initialize water heater device. | Initialize water heater device. | def __init__(self, api: MelCloudDevice, device: AtwDevice) -> None:
"""Initialize water heater device."""
self._api = api
self._device = device
self._name = device.name | [
"def",
"__init__",
"(",
"self",
",",
"api",
":",
"MelCloudDevice",
",",
"device",
":",
"AtwDevice",
")",
"->",
"None",
":",
"self",
".",
"_api",
"=",
"api",
"self",
".",
"_device",
"=",
"device",
"self",
".",
"_name",
"=",
"device",
".",
"name"
] | [
40,
4
] | [
44,
32
] | python | en | ['nl', 'en', 'en'] | True |
AtwWaterHeater.async_update | (self) | Update state from MELCloud. | Update state from MELCloud. | async def async_update(self):
"""Update state from MELCloud."""
await self._api.async_update() | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"_api",
".",
"async_update",
"(",
")"
] | [
46,
4
] | [
48,
38
] | python | en | ['en', 'en', 'en'] | True |
AtwWaterHeater.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> Optional[str]:
"""Return a unique ID."""
return f"{self._api.device.serial}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"f\"{self._api.device.serial}\""
] | [
51,
4
] | [
53,
43
] | python | ca | ['fr', 'ca', 'en'] | False |
AtwWaterHeater.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"
] | [
56,
4
] | [
58,
25
] | python | en | ['en', 'en', 'en'] | True |
AtwWaterHeater.device_info | (self) | Return a device description for device registry. | Return a device description for device registry. | def device_info(self):
"""Return a device description for device registry."""
return self._api.device_info | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"self",
".",
"_api",
".",
"device_info"
] | [
61,
4
] | [
63,
36
] | python | en | ['ro', 'fr', 'en'] | False |
AtwWaterHeater.async_turn_on | (self) | Turn the entity on. | Turn the entity on. | async def async_turn_on(self) -> None:
"""Turn the entity on."""
await self._device.set({PROPERTY_POWER: True}) | [
"async",
"def",
"async_turn_on",
"(",
"self",
")",
"->",
"None",
":",
"await",
"self",
".",
"_device",
".",
"set",
"(",
"{",
"PROPERTY_POWER",
":",
"True",
"}",
")"
] | [
65,
4
] | [
67,
54
] | python | en | ['en', 'en', 'en'] | True |
AtwWaterHeater.async_turn_off | (self) | Turn the entity off. | Turn the entity off. | async def async_turn_off(self) -> None:
"""Turn the entity off."""
await self._device.set({PROPERTY_POWER: False}) | [
"async",
"def",
"async_turn_off",
"(",
"self",
")",
"->",
"None",
":",
"await",
"self",
".",
"_device",
".",
"set",
"(",
"{",
"PROPERTY_POWER",
":",
"False",
"}",
")"
] | [
69,
4
] | [
71,
55
] | python | en | ['en', 'en', 'en'] | True |
AtwWaterHeater.device_state_attributes | (self) | Return the optional state attributes with device specific additions. | Return the optional state attributes with device specific additions. | def device_state_attributes(self):
"""Return the optional state attributes with device specific additions."""
data = {ATTR_STATUS: self._device.status}
return data | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"data",
"=",
"{",
"ATTR_STATUS",
":",
"self",
".",
"_device",
".",
"status",
"}",
"return",
"data"
] | [
74,
4
] | [
77,
19
] | python | en | ['en', 'en', 'en'] | True |
AtwWaterHeater.temperature_unit | (self) | Return the unit of measurement used by the platform. | Return the unit of measurement used by the platform. | def temperature_unit(self) -> str:
"""Return the unit of measurement used by the platform."""
return TEMP_CELSIUS | [
"def",
"temperature_unit",
"(",
"self",
")",
"->",
"str",
":",
"return",
"TEMP_CELSIUS"
] | [
80,
4
] | [
82,
27
] | python | en | ['en', 'en', 'en'] | True |
AtwWaterHeater.current_operation | (self) | Return current operation as reported by pymelcloud. | Return current operation as reported by pymelcloud. | def current_operation(self) -> Optional[str]:
"""Return current operation as reported by pymelcloud."""
return self._device.operation_mode | [
"def",
"current_operation",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_device",
".",
"operation_mode"
] | [
85,
4
] | [
87,
42
] | python | en | ['en', 'en', 'en'] | True |
AtwWaterHeater.operation_list | (self) | Return the list of available operation modes as reported by pymelcloud. | Return the list of available operation modes as reported by pymelcloud. | def operation_list(self) -> List[str]:
"""Return the list of available operation modes as reported by pymelcloud."""
return self._device.operation_modes | [
"def",
"operation_list",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_device",
".",
"operation_modes"
] | [
90,
4
] | [
92,
43
] | python | en | ['en', 'en', 'en'] | True |
AtwWaterHeater.current_temperature | (self) | Return the current temperature. | Return the current temperature. | def current_temperature(self) -> Optional[float]:
"""Return the current temperature."""
return self._device.tank_temperature | [
"def",
"current_temperature",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"return",
"self",
".",
"_device",
".",
"tank_temperature"
] | [
95,
4
] | [
97,
44
] | python | en | ['en', 'la', 'en'] | True |
AtwWaterHeater.target_temperature | (self) | Return the temperature we try to reach. | Return the temperature we try to reach. | def target_temperature(self):
"""Return the temperature we try to reach."""
return self._device.target_tank_temperature | [
"def",
"target_temperature",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"target_tank_temperature"
] | [
100,
4
] | [
102,
51
] | python | en | ['en', 'en', 'en'] | True |
AtwWaterHeater.async_set_temperature | (self, **kwargs) | Set new target temperature. | Set new target temperature. | async def async_set_temperature(self, **kwargs):
"""Set new target temperature."""
await self._device.set(
{
PROPERTY_TARGET_TANK_TEMPERATURE: kwargs.get(
"temperature", self.target_temperature
)
}
) | [
"async",
"def",
"async_set_temperature",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_device",
".",
"set",
"(",
"{",
"PROPERTY_TARGET_TANK_TEMPERATURE",
":",
"kwargs",
".",
"get",
"(",
"\"temperature\"",
",",
"self",
".",
"target_t... | [
104,
4
] | [
112,
9
] | python | en | ['en', 'ca', 'en'] | True |
AtwWaterHeater.async_set_operation_mode | (self, operation_mode) | Set new target operation mode. | Set new target operation mode. | async def async_set_operation_mode(self, operation_mode):
"""Set new target operation mode."""
await self._device.set({PROPERTY_OPERATION_MODE: operation_mode}) | [
"async",
"def",
"async_set_operation_mode",
"(",
"self",
",",
"operation_mode",
")",
":",
"await",
"self",
".",
"_device",
".",
"set",
"(",
"{",
"PROPERTY_OPERATION_MODE",
":",
"operation_mode",
"}",
")"
] | [
114,
4
] | [
116,
73
] | python | en | ['nl', 'en', 'en'] | True |
AtwWaterHeater.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self):
"""Return the list of supported features."""
return SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_TARGET_TEMPERATURE",
"|",
"SUPPORT_OPERATION_MODE"
] | [
119,
4
] | [
121,
66
] | python | en | ['en', 'en', 'en'] | True |
AtwWaterHeater.min_temp | (self) | Return the minimum temperature. | Return the minimum temperature. | def min_temp(self) -> Optional[float]:
"""Return the minimum temperature."""
return self._device.target_tank_temperature_min | [
"def",
"min_temp",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"return",
"self",
".",
"_device",
".",
"target_tank_temperature_min"
] | [
124,
4
] | [
126,
55
] | python | en | ['en', 'la', 'en'] | True |
AtwWaterHeater.max_temp | (self) | Return the maximum temperature. | Return the maximum temperature. | def max_temp(self) -> Optional[float]:
"""Return the maximum temperature."""
return self._device.target_tank_temperature_max | [
"def",
"max_temp",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"return",
"self",
".",
"_device",
".",
"target_tank_temperature_max"
] | [
129,
4
] | [
131,
55
] | python | en | ['en', 'la', 'en'] | True |
CameraEntityPreferences.__init__ | (self, prefs) | Initialize prefs. | Initialize prefs. | def __init__(self, prefs):
"""Initialize prefs."""
self._prefs = prefs | [
"def",
"__init__",
"(",
"self",
",",
"prefs",
")",
":",
"self",
".",
"_prefs",
"=",
"prefs"
] | [
13,
4
] | [
15,
27
] | python | en | ['en', 'pl', 'it'] | False |
CameraEntityPreferences.as_dict | (self) | Return dictionary version. | Return dictionary version. | def as_dict(self):
"""Return dictionary version."""
return self._prefs | [
"def",
"as_dict",
"(",
"self",
")",
":",
"return",
"self",
".",
"_prefs"
] | [
17,
4
] | [
19,
26
] | python | en | ['en', 'en', 'en'] | True |
CameraEntityPreferences.preload_stream | (self) | Return if stream is loaded on hass start. | Return if stream is loaded on hass start. | def preload_stream(self):
"""Return if stream is loaded on hass start."""
return self._prefs.get(PREF_PRELOAD_STREAM, False) | [
"def",
"preload_stream",
"(",
"self",
")",
":",
"return",
"self",
".",
"_prefs",
".",
"get",
"(",
"PREF_PRELOAD_STREAM",
",",
"False",
")"
] | [
22,
4
] | [
24,
58
] | python | en | ['en', 'en', 'en'] | True |
CameraPreferences.__init__ | (self, hass) | Initialize camera prefs. | Initialize camera prefs. | def __init__(self, hass):
"""Initialize camera prefs."""
self._hass = hass
self._store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY)
self._prefs = None | [
"def",
"__init__",
"(",
"self",
",",
"hass",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_store",
"=",
"hass",
".",
"helpers",
".",
"storage",
".",
"Store",
"(",
"STORAGE_VERSION",
",",
"STORAGE_KEY",
")",
"self",
".",
"_prefs",
"=",
"... | [
30,
4
] | [
34,
26
] | python | co | ['es', 'co', 'it'] | False |
CameraPreferences.async_initialize | (self) | Finish initializing the preferences. | Finish initializing the preferences. | async def async_initialize(self):
"""Finish initializing the preferences."""
prefs = await self._store.async_load()
if prefs is None:
prefs = {}
self._prefs = prefs | [
"async",
"def",
"async_initialize",
"(",
"self",
")",
":",
"prefs",
"=",
"await",
"self",
".",
"_store",
".",
"async_load",
"(",
")",
"if",
"prefs",
"is",
"None",
":",
"prefs",
"=",
"{",
"}",
"self",
".",
"_prefs",
"=",
"prefs"
] | [
36,
4
] | [
43,
27
] | python | en | ['en', 'zu', 'en'] | True |
CameraPreferences.async_update | (
self, entity_id, *, preload_stream=_UNDEF, stream_options=_UNDEF
) | Update camera preferences. | Update camera preferences. | async def async_update(
self, entity_id, *, preload_stream=_UNDEF, stream_options=_UNDEF
):
"""Update camera preferences."""
if not self._prefs.get(entity_id):
self._prefs[entity_id] = {}
for key, value in ((PREF_PRELOAD_STREAM, preload_stream),):
if value is... | [
"async",
"def",
"async_update",
"(",
"self",
",",
"entity_id",
",",
"*",
",",
"preload_stream",
"=",
"_UNDEF",
",",
"stream_options",
"=",
"_UNDEF",
")",
":",
"if",
"not",
"self",
".",
"_prefs",
".",
"get",
"(",
"entity_id",
")",
":",
"self",
".",
"_pr... | [
45,
4
] | [
56,
49
] | python | co | ['es', 'co', 'en'] | False |
CameraPreferences.get | (self, entity_id) | Get preferences for an entity. | Get preferences for an entity. | def get(self, entity_id):
"""Get preferences for an entity."""
return CameraEntityPreferences(self._prefs.get(entity_id, {})) | [
"def",
"get",
"(",
"self",
",",
"entity_id",
")",
":",
"return",
"CameraEntityPreferences",
"(",
"self",
".",
"_prefs",
".",
"get",
"(",
"entity_id",
",",
"{",
"}",
")",
")"
] | [
58,
4
] | [
60,
70
] | python | en | ['en', 'en', 'en'] | True |
run | (argv=None) | The main function which creates the pipeline and runs it. | The main function which creates the pipeline and runs it. | def run(argv=None):
"""The main function which creates the pipeline and runs it."""
parser = argparse.ArgumentParser()
# Here we add some specific command line arguments we expect. S
# This defaults the output table in your BigQuery you'll have
# to create the example_data dataset yourself using b... | [
"def",
"run",
"(",
"argv",
"=",
"None",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"# Here we add some specific command line arguments we expect. S",
"# This defaults the output table in your BigQuery you'll have",
"# to create the example_data dataset ... | [
225,
0
] | [
300,
31
] | python | en | ['en', 'en', 'en'] | True |
DataLakeToDataMart.get_orders_query | (self) | This returns a query against a very large fact table. We are
using a fake orders dataset to simulate a fact table in a typical
data warehouse. | This returns a query against a very large fact table. We are
using a fake orders dataset to simulate a fact table in a typical
data warehouse. | def get_orders_query(self):
"""This returns a query against a very large fact table. We are
using a fake orders dataset to simulate a fact table in a typical
data warehouse."""
orders_query = """SELECT
acct_number,
col_number,
col_number_1,
... | [
"def",
"get_orders_query",
"(",
"self",
")",
":",
"orders_query",
"=",
"\"\"\"SELECT\n acct_number,\n col_number,\n col_number_1,\n col_number_10,\n col_number_100,\n col_number_101,\n col_number_102,\n col_numbe... | [
48,
4
] | [
206,
27
] | python | en | ['en', 'en', 'en'] | True |
DataLakeToDataMart.add_account_details | (self, row, account_details) | add_account_details joins two datasets together. Dataflow passes in the
a row from the orders dataset along with the entire account details dataset.
This works because the entire account details dataset can be passed in memory.
The function then looks up the account details, and adds all colu... | add_account_details joins two datasets together. Dataflow passes in the
a row from the orders dataset along with the entire account details dataset. | def add_account_details(self, row, account_details):
"""add_account_details joins two datasets together. Dataflow passes in the
a row from the orders dataset along with the entire account details dataset.
This works because the entire account details dataset can be passed in memory.
T... | [
"def",
"add_account_details",
"(",
"self",
",",
"row",
",",
"account_details",
")",
":",
"result",
"=",
"row",
".",
"copy",
"(",
")",
"try",
":",
"result",
".",
"update",
"(",
"account_details",
"[",
"row",
"[",
"'acct_number'",
"]",
"]",
")",
"except",
... | [
208,
4
] | [
222,
21
] | python | en | ['en', 'en', 'en'] | True |
run_auth_get_access_token | (
hass,
aioclient_mock,
expires_in,
client_id,
client_secret,
accept_grant_code,
refresh_token,
) | Do auth and request a new token for tests. | Do auth and request a new token for tests. | async def run_auth_get_access_token(
hass,
aioclient_mock,
expires_in,
client_id,
client_secret,
accept_grant_code,
refresh_token,
):
"""Do auth and request a new token for tests."""
aioclient_mock.post(
TEST_TOKEN_URL,
json={
"access_token": "the_access_t... | [
"async",
"def",
"run_auth_get_access_token",
"(",
"hass",
",",
"aioclient_mock",
",",
"expires_in",
",",
"client_id",
",",
"client_secret",
",",
"accept_grant_code",
",",
"refresh_token",
",",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"TEST_TOKEN_URL",
",",
"j... | [
7,
0
] | [
28,
39
] | python | en | ['en', 'en', 'en'] | True |
test_auth_get_access_token_expired | (hass, aioclient_mock) | Test the auth get access token function. | Test the auth get access token function. | async def test_auth_get_access_token_expired(hass, aioclient_mock):
"""Test the auth get access token function."""
client_id = "client123"
client_secret = "shhhhh"
accept_grant_code = "abcdefg"
refresh_token = "refresher"
await run_auth_get_access_token(
hass,
aioclient_mock,
... | [
"async",
"def",
"test_auth_get_access_token_expired",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"client_id",
"=",
"\"client123\"",
"client_secret",
"=",
"\"shhhhh\"",
"accept_grant_code",
"=",
"\"abcdefg\"",
"refresh_token",
"=",
"\"refresher\"",
"await",
"run_auth_ge... | [
31,
0
] | [
62,
63
] | python | en | ['en', 'en', 'en'] | True |
test_auth_get_access_token_not_expired | (hass, aioclient_mock) | Test the auth get access token function. | Test the auth get access token function. | async def test_auth_get_access_token_not_expired(hass, aioclient_mock):
"""Test the auth get access token function."""
client_id = "client123"
client_secret = "shhhhh"
accept_grant_code = "abcdefg"
refresh_token = "refresher"
await run_auth_get_access_token(
hass,
aioclient_mock... | [
"async",
"def",
"test_auth_get_access_token_not_expired",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"client_id",
"=",
"\"client123\"",
"client_secret",
"=",
"\"shhhhh\"",
"accept_grant_code",
"=",
"\"abcdefg\"",
"refresh_token",
"=",
"\"refresher\"",
"await",
"run_aut... | [
65,
0
] | [
90,
62
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up switch(es) for KNX platform. | Set up switch(es) for KNX platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up switch(es) for KNX platform."""
entities = []
for device in hass.data[DOMAIN].xknx.devices:
if isinstance(device, XknxSwitch):
entities.append(KNXSwitch(device))
async_add_entities(entiti... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"entities",
"=",
"[",
"]",
"for",
"device",
"in",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"xknx",
".",
"dev... | [
9,
0
] | [
15,
32
] | python | en | ['en', 'da', 'en'] | True |
KNXSwitch.__init__ | (self, device: XknxSwitch) | Initialize of KNX switch. | Initialize of KNX switch. | def __init__(self, device: XknxSwitch):
"""Initialize of KNX switch."""
super().__init__(device) | [
"def",
"__init__",
"(",
"self",
",",
"device",
":",
"XknxSwitch",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"device",
")"
] | [
21,
4
] | [
23,
32
] | python | en | ['en', 'pl', 'en'] | True |
KNXSwitch.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._device.state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"state"
] | [
26,
4
] | [
28,
33
] | python | en | ['en', 'fy', 'en'] | True |
KNXSwitch.async_turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | async def async_turn_on(self, **kwargs):
"""Turn the device on."""
await self._device.set_on() | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_device",
".",
"set_on",
"(",
")"
] | [
30,
4
] | [
32,
35
] | python | en | ['en', 'en', 'en'] | True |
KNXSwitch.async_turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | async def async_turn_off(self, **kwargs):
"""Turn the device off."""
await self._device.set_off() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_device",
".",
"set_off",
"(",
")"
] | [
34,
4
] | [
36,
36
] | python | en | ['en', 'en', 'en'] | True |
_mock_get_config | () | Return a default griddy config. | Return a default griddy config. | def _mock_get_config():
"""Return a default griddy config."""
return {DOMAIN: {CONF_LOADZONE: "LZ_HOUSTON"}} | [
"def",
"_mock_get_config",
"(",
")",
":",
"return",
"{",
"DOMAIN",
":",
"{",
"CONF_LOADZONE",
":",
"\"LZ_HOUSTON\"",
"}",
"}"
] | [
20,
0
] | [
22,
50
] | python | ca | ['ca', 'da', 'en'] | False |
test_houston_loadzone | (hass) | Test creation of the houston load zone. | Test creation of the houston load zone. | async def test_houston_loadzone(hass):
"""Test creation of the houston load zone."""
getnow_json = await _load_json_fixture(hass, "getnow.json")
griddy_price_data = GriddyPriceData(getnow_json)
with patch(
"homeassistant.components.griddy.AsyncGriddy.async_getnow",
return_value=griddy_p... | [
"async",
"def",
"test_houston_loadzone",
"(",
"hass",
")",
":",
"getnow_json",
"=",
"await",
"_load_json_fixture",
"(",
"hass",
",",
"\"getnow.json\"",
")",
"griddy_price_data",
"=",
"GriddyPriceData",
"(",
"getnow_json",
")",
"with",
"patch",
"(",
"\"homeassistant.... | [
25,
0
] | [
38,
55
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the SleepIQ sensors. | Set up the SleepIQ sensors. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the SleepIQ sensors."""
if discovery_info is None:
return
data = hass.data[DOMAIN]
data.update()
dev = []
for bed_id, bed in data.beds.items():
for side in SIDES:
if getattr(bed, side) is... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"data",
".",
"update",
"(",... | [
7,
0
] | [
20,
21
] | python | en | ['en', 'bg', 'en'] | True |
SleepNumberSensor.__init__ | (self, sleepiq_data, bed_id, side) | Initialize the sensor. | Initialize the sensor. | def __init__(self, sleepiq_data, bed_id, side):
"""Initialize the sensor."""
SleepIQSensor.__init__(self, sleepiq_data, bed_id, side)
self._state = None
self.type = SLEEP_NUMBER
self._name = SENSOR_TYPES[self.type]
self.update() | [
"def",
"__init__",
"(",
"self",
",",
"sleepiq_data",
",",
"bed_id",
",",
"side",
")",
":",
"SleepIQSensor",
".",
"__init__",
"(",
"self",
",",
"sleepiq_data",
",",
"bed_id",
",",
"side",
")",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"type",
"="... | [
26,
4
] | [
34,
21
] | python | en | ['en', 'en', 'en'] | True |
SleepNumberSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
37,
4
] | [
39,
26
] | python | en | ['en', 'en', 'en'] | True |
SleepNumberSensor.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
42,
4
] | [
44,
19
] | python | en | ['en', 'en', 'en'] | True |
SleepNumberSensor.update | (self) | Get the latest data from SleepIQ and updates the states. | Get the latest data from SleepIQ and updates the states. | def update(self):
"""Get the latest data from SleepIQ and updates the states."""
SleepIQSensor.update(self)
self._state = self.side.sleep_number | [
"def",
"update",
"(",
"self",
")",
":",
"SleepIQSensor",
".",
"update",
"(",
"self",
")",
"self",
".",
"_state",
"=",
"self",
".",
"side",
".",
"sleep_number"
] | [
46,
4
] | [
49,
44
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the air_quality kaiterra sensor. | Set up the air_quality kaiterra sensor. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the air_quality kaiterra sensor."""
if discovery_info is None:
return
api = hass.data[DOMAIN]
name = discovery_info[CONF_NAME]
device_id = discovery_info[CONF_DEVICE_ID]
async_add_entities(... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"api",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"name",
"... | [
14,
0
] | [
23,
66
] | python | en | ['en', 'pt', 'en'] | True |
KaiterraAirQuality.__init__ | (self, api, name, device_id) | Initialize the sensor. | Initialize the sensor. | def __init__(self, api, name, device_id):
"""Initialize the sensor."""
self._api = api
self._name = f"{name} Air Quality"
self._device_id = device_id | [
"def",
"__init__",
"(",
"self",
",",
"api",
",",
"name",
",",
"device_id",
")",
":",
"self",
".",
"_api",
"=",
"api",
"self",
".",
"_name",
"=",
"f\"{name} Air Quality\"",
"self",
".",
"_device_id",
"=",
"device_id"
] | [
29,
4
] | [
33,
35
] | python | en | ['en', 'en', 'en'] | True |
KaiterraAirQuality.should_poll | (self) | Return that the sensor should not be polled. | Return that the sensor should not be polled. | def should_poll(self):
"""Return that the sensor should not be polled."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
43,
4
] | [
45,
20
] | python | en | ['en', 'en', 'en'] | True |
KaiterraAirQuality.available | (self) | Return the availability of the sensor. | Return the availability of the sensor. | def available(self):
"""Return the availability of the sensor."""
return self._api.data.get(self._device_id) is not None | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_api",
".",
"data",
".",
"get",
"(",
"self",
".",
"_device_id",
")",
"is",
"not",
"None"
] | [
48,
4
] | [
50,
62
] | python | en | ['en', 'ga', 'en'] | True |
KaiterraAirQuality.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
53,
4
] | [
55,
25
] | python | en | ['en', 'mi', 'en'] | True |
KaiterraAirQuality.air_quality_index | (self) | Return the Air Quality Index (AQI). | Return the Air Quality Index (AQI). | def air_quality_index(self):
"""Return the Air Quality Index (AQI)."""
return self._data("aqi") | [
"def",
"air_quality_index",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
"(",
"\"aqi\"",
")"
] | [
58,
4
] | [
60,
32
] | python | en | ['en', 'cy', 'en'] | True |
KaiterraAirQuality.air_quality_index_level | (self) | Return the Air Quality Index level. | Return the Air Quality Index level. | def air_quality_index_level(self):
"""Return the Air Quality Index level."""
return self._data("aqi_level") | [
"def",
"air_quality_index_level",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
"(",
"\"aqi_level\"",
")"
] | [
63,
4
] | [
65,
38
] | python | en | ['en', 'en', 'en'] | True |
KaiterraAirQuality.air_quality_index_pollutant | (self) | Return the Air Quality Index level. | Return the Air Quality Index level. | def air_quality_index_pollutant(self):
"""Return the Air Quality Index level."""
return self._data("aqi_pollutant") | [
"def",
"air_quality_index_pollutant",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
"(",
"\"aqi_pollutant\"",
")"
] | [
68,
4
] | [
70,
42
] | python | en | ['en', 'en', 'en'] | True |
KaiterraAirQuality.particulate_matter_2_5 | (self) | Return the particulate matter 2.5 level. | Return the particulate matter 2.5 level. | def particulate_matter_2_5(self):
"""Return the particulate matter 2.5 level."""
return self._data("rpm25c") | [
"def",
"particulate_matter_2_5",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
"(",
"\"rpm25c\"",
")"
] | [
73,
4
] | [
75,
35
] | python | en | ['en', 'en', 'en'] | True |
KaiterraAirQuality.particulate_matter_10 | (self) | Return the particulate matter 10 level. | Return the particulate matter 10 level. | def particulate_matter_10(self):
"""Return the particulate matter 10 level."""
return self._data("rpm10c") | [
"def",
"particulate_matter_10",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
"(",
"\"rpm10c\"",
")"
] | [
78,
4
] | [
80,
35
] | python | en | ['en', 'en', 'en'] | True |
KaiterraAirQuality.carbon_dioxide | (self) | Return the CO2 (carbon dioxide) level. | Return the CO2 (carbon dioxide) level. | def carbon_dioxide(self):
"""Return the CO2 (carbon dioxide) level."""
return self._data("rco2") | [
"def",
"carbon_dioxide",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
"(",
"\"rco2\"",
")"
] | [
83,
4
] | [
85,
33
] | python | en | ['en', 'en', 'en'] | True |
KaiterraAirQuality.volatile_organic_compounds | (self) | Return the VOC (Volatile Organic Compounds) level. | Return the VOC (Volatile Organic Compounds) level. | def volatile_organic_compounds(self):
"""Return the VOC (Volatile Organic Compounds) level."""
return self._data("rtvoc") | [
"def",
"volatile_organic_compounds",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
"(",
"\"rtvoc\"",
")"
] | [
88,
4
] | [
90,
34
] | python | en | ['en', 'fr', 'en'] | True |
KaiterraAirQuality.unique_id | (self) | Return the sensor's unique id. | Return the sensor's unique id. | def unique_id(self):
"""Return the sensor's unique id."""
return f"{self._device_id}_air_quality" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self._device_id}_air_quality\""
] | [
93,
4
] | [
95,
47
] | python | en | ['en', 'ca', 'en'] | True |
KaiterraAirQuality.device_state_attributes | (self) | Return the device state attributes. | Return the device state attributes. | def device_state_attributes(self):
"""Return the device state attributes."""
data = {}
attributes = [
(ATTR_VOC, self.volatile_organic_compounds),
(ATTR_AQI_LEVEL, self.air_quality_index_level),
(ATTR_AQI_POLLUTANT, self.air_quality_index_pollutant),
]... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"data",
"=",
"{",
"}",
"attributes",
"=",
"[",
"(",
"ATTR_VOC",
",",
"self",
".",
"volatile_organic_compounds",
")",
",",
"(",
"ATTR_AQI_LEVEL",
",",
"self",
".",
"air_quality_index_level",
")",
",",
"... | [
98,
4
] | [
111,
19
] | python | en | ['en', 'en', 'en'] | True |
KaiterraAirQuality.async_added_to_hass | (self) | Register callback. | Register callback. | async def async_added_to_hass(self):
"""Register callback."""
self.async_on_remove(
async_dispatcher_connect(
self.hass, DISPATCHER_KAITERRA, self.async_write_ha_state
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"DISPATCHER_KAITERRA",
",",
"self",
".",
"async_write_ha_state",
")",
")"
] | [
113,
4
] | [
119,
9
] | python | en | ['en', 'no', 'en'] | False |
run_to_end | (env: Env) | Run the end of env | Run the end of env | def run_to_end(env: Env):
"""Run the end of env"""
is_done = False
while not is_done:
_, _, is_done = env.step(None) | [
"def",
"run_to_end",
"(",
"env",
":",
"Env",
")",
":",
"is_done",
"=",
"False",
"while",
"not",
"is_done",
":",
"_",
",",
"_",
",",
"is_done",
"=",
"env",
".",
"step",
"(",
"None",
")"
] | [
15,
0
] | [
20,
38
] | python | en | ['en', 'gl', 'en'] | True |
TestEnv.test_builtin_scenario_with_default_parameters | (self) | Test if the env with built-in scenario initializing correct | Test if the env with built-in scenario initializing correct | def test_builtin_scenario_with_default_parameters(self):
"""Test if the env with built-in scenario initializing correct"""
for backend_name in backends_to_test:
os.environ["DEFAULT_BACKEND_NAME"] = backend_name
max_tick = 10
env = Env(scenario="cim", topology="toy.5... | [
"def",
"test_builtin_scenario_with_default_parameters",
"(",
"self",
")",
":",
"for",
"backend_name",
"in",
"backends_to_test",
":",
"os",
".",
"environ",
"[",
"\"DEFAULT_BACKEND_NAME\"",
"]",
"=",
"backend_name",
"max_tick",
"=",
"10",
"env",
"=",
"Env",
"(",
"sc... | [
28,
4
] | [
44,
101
] | python | en | ['en', 'en', 'en'] | True |
TestEnv.test_env_interfaces_with_specified_business_engine_cls | (self) | Test if env interfaces works as expect | Test if env interfaces works as expect | def test_env_interfaces_with_specified_business_engine_cls(self):
"""Test if env interfaces works as expect"""
for backend_name in backends_to_test:
os.environ["DEFAULT_BACKEND_NAME"] = backend_name
max_tick = 5
env = Env(business_engine_cls=DummyEngine,
... | [
"def",
"test_env_interfaces_with_specified_business_engine_cls",
"(",
"self",
")",
":",
"for",
"backend_name",
"in",
"backends_to_test",
":",
"os",
".",
"environ",
"[",
"\"DEFAULT_BACKEND_NAME\"",
"]",
"=",
"backend_name",
"max_tick",
"=",
"5",
"env",
"=",
"Env",
"(... | [
46,
4
] | [
135,
91
] | python | en | ['en', 'en', 'en'] | True |
TestEnv.test_snapshot_resolution | (self) | Test env with snapshot_resolution, it should take snapshot every snapshot_resolution ticks | Test env with snapshot_resolution, it should take snapshot every snapshot_resolution ticks | def test_snapshot_resolution(self):
"""Test env with snapshot_resolution, it should take snapshot every snapshot_resolution ticks"""
for backend_name in backends_to_test:
os.environ["DEFAULT_BACKEND_NAME"] = backend_name
max_tick = 10
env = Env(business_engine_cls=... | [
"def",
"test_snapshot_resolution",
"(",
"self",
")",
":",
"for",
"backend_name",
"in",
"backends_to_test",
":",
"os",
".",
"environ",
"[",
"\"DEFAULT_BACKEND_NAME\"",
"]",
"=",
"backend_name",
"max_tick",
"=",
"10",
"env",
"=",
"Env",
"(",
"business_engine_cls",
... | [
137,
4
] | [
161,
80
] | python | en | ['en', 'en', 'en'] | True |
TestEnv.test_max_snapshots | (self) | Test env with max_snapshots, it should take snapshot every tick, but should last N kept | Test env with max_snapshots, it should take snapshot every tick, but should last N kept | def test_max_snapshots(self):
"""Test env with max_snapshots, it should take snapshot every tick, but should last N kept"""
for backend_name in backends_to_test:
os.environ["DEFAULT_BACKEND_NAME"] = backend_name
max_tick = 10
env = Env(business_engine_cls=DummyEngi... | [
"def",
"test_max_snapshots",
"(",
"self",
")",
":",
"for",
"backend_name",
"in",
"backends_to_test",
":",
"os",
".",
"environ",
"[",
"\"DEFAULT_BACKEND_NAME\"",
"]",
"=",
"backend_name",
"max_tick",
"=",
"10",
"env",
"=",
"Env",
"(",
"business_engine_cls",
"=",
... | [
163,
4
] | [
188,
82
] | python | en | ['en', 'en', 'en'] | True |
TestEnv.test_snapshot_resolution_with_max_snapshots | (self) | Test env with both snapshot_resolution and max_snapshots parameters, and it should work as expected | Test env with both snapshot_resolution and max_snapshots parameters, and it should work as expected | def test_snapshot_resolution_with_max_snapshots(self):
"""Test env with both snapshot_resolution and max_snapshots parameters, and it should work as expected"""
for backend_name in backends_to_test:
os.environ["DEFAULT_BACKEND_NAME"] = backend_name
max_tick = 10
env... | [
"def",
"test_snapshot_resolution_with_max_snapshots",
"(",
"self",
")",
":",
"for",
"backend_name",
"in",
"backends_to_test",
":",
"os",
".",
"environ",
"[",
"\"DEFAULT_BACKEND_NAME\"",
"]",
"=",
"backend_name",
"max_tick",
"=",
"10",
"env",
"=",
"Env",
"(",
"busi... | [
190,
4
] | [
215,
82
] | python | en | ['en', 'en', 'en'] | True |
TestEnv.test_early_stop | (self) | Test if we can stop at specified tick with early stop at post_step function | Test if we can stop at specified tick with early stop at post_step function | def test_early_stop(self):
"""Test if we can stop at specified tick with early stop at post_step function"""
for backend_name in backends_to_test:
os.environ["DEFAULT_BACKEND_NAME"] = backend_name
max_tick = 10
env = Env(business_engine_cls=DummyEngine, start_tick=0... | [
"def",
"test_early_stop",
"(",
"self",
")",
":",
"for",
"backend_name",
"in",
"backends_to_test",
":",
"os",
".",
"environ",
"[",
"\"DEFAULT_BACKEND_NAME\"",
"]",
"=",
"backend_name",
"max_tick",
"=",
"10",
"env",
"=",
"Env",
"(",
"business_engine_cls",
"=",
"... | [
217,
4
] | [
241,
72
] | python | en | ['en', 'en', 'en'] | True |
TestEnv.test_builtin_scenario_with_customized_topology | (self) | Test using built-in scenario with customized topology | Test using built-in scenario with customized topology | def test_builtin_scenario_with_customized_topology(self):
"""Test using built-in scenario with customized topology"""
for backend_name in backends_to_test:
os.environ["DEFAULT_BACKEND_NAME"] = backend_name
max_tick = 10
env = Env(scenario="cim", topology="tests/data... | [
"def",
"test_builtin_scenario_with_customized_topology",
"(",
"self",
")",
":",
"for",
"backend_name",
"in",
"backends_to_test",
":",
"os",
".",
"environ",
"[",
"\"DEFAULT_BACKEND_NAME\"",
"]",
"=",
"backend_name",
"max_tick",
"=",
"10",
"env",
"=",
"Env",
"(",
"s... | [
243,
4
] | [
257,
76
] | python | en | ['en', 'en', 'en'] | True |
TestEnv.test_invalid_scenario | (self) | Test specified invalid scenario | Test specified invalid scenario | def test_invalid_scenario(self):
"""Test specified invalid scenario"""
# not exist scenario
with self.assertRaises(ModuleNotFoundError) as ctx:
env = Env("None", "toy.5p_ssddd_l0.0", 100)
# not exist topology
with self.assertRaises(FileNotFoundError) as ctx:
... | [
"def",
"test_invalid_scenario",
"(",
"self",
")",
":",
"# not exist scenario",
"with",
"self",
".",
"assertRaises",
"(",
"ModuleNotFoundError",
")",
"as",
"ctx",
":",
"env",
"=",
"Env",
"(",
"\"None\"",
",",
"\"toy.5p_ssddd_l0.0\"",
",",
"100",
")",
"# not exist... | [
259,
4
] | [
268,
41
] | python | en | ['en', 'en', 'en'] | True |
test_reload | (hass) | Verify we can reload trend sensors. | Verify we can reload trend sensors. | async def test_reload(hass):
"""Verify we can reload trend sensors."""
await setup.async_setup_component(
hass,
"binary_sensor",
{
"binary_sensor": {
"platform": "ping",
"name": "test",
"host": "127.0.0.1",
"cou... | [
"async",
"def",
"test_reload",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"binary_sensor\"",
",",
"{",
"\"binary_sensor\"",
":",
"{",
"\"platform\"",
":",
"\"ping\"",
",",
"\"name\"",
":",
"\"test\"",
",",
"\"hos... | [
10,
0
] | [
48,
49
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Initialize the Google Domains component. | Initialize the Google Domains component. | async def async_setup(hass, config):
"""Initialize the Google Domains component."""
domain = config[DOMAIN].get(CONF_DOMAIN)
user = config[DOMAIN].get(CONF_USERNAME)
password = config[DOMAIN].get(CONF_PASSWORD)
timeout = config[DOMAIN].get(CONF_TIMEOUT)
session = hass.helpers.aiohttp_client.asy... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"domain",
"=",
"config",
"[",
"DOMAIN",
"]",
".",
"get",
"(",
"CONF_DOMAIN",
")",
"user",
"=",
"config",
"[",
"DOMAIN",
"]",
".",
"get",
"(",
"CONF_USERNAME",
")",
"password",
"=",
... | [
35,
0
] | [
57,
15
] | python | en | ['en', 'en', 'en'] | True |
_update_google_domains | (hass, session, domain, user, password, timeout) | Update Google Domains. | Update Google Domains. | async def _update_google_domains(hass, session, domain, user, password, timeout):
"""Update Google Domains."""
url = f"https://{user}:{password}@domains.google.com/nic/update"
params = {"hostname": domain}
try:
with async_timeout.timeout(timeout):
resp = await session.get(url, para... | [
"async",
"def",
"_update_google_domains",
"(",
"hass",
",",
"session",
",",
"domain",
",",
"user",
",",
"password",
",",
"timeout",
")",
":",
"url",
"=",
"f\"https://{user}:{password}@domains.google.com/nic/update\"",
"params",
"=",
"{",
"\"hostname\"",
":",
"domain... | [
60,
0
] | [
82,
16
] | python | en | ['en', 'en', 'en'] | True |
RagPreTrainedModel.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.
The model is set in evaluation mode by default using :obj:`model.eval()` (Dropout modules are deactivated). To
train the model, you need to first set it b... | 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
) -> PreTrainedModel:
r"""
Insta... | [
"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",
",... | [
235,
4
] | [
366,
110
] | python | cy | ['en', 'cy', 'hi'] | False |
AbstractGraphListener.on_metric | (self, model: Model, metric: MetricData) |
Reports the final metric of a graph.
|
Reports the final metric of a graph.
| def on_metric(self, model: Model, metric: MetricData) -> None:
"""
Reports the final metric of a graph.
"""
raise NotImplementedError | [
"def",
"on_metric",
"(",
"self",
",",
"model",
":",
"Model",
",",
"metric",
":",
"MetricData",
")",
"->",
"None",
":",
"raise",
"NotImplementedError"
] | [
44,
4
] | [
48,
33
] | python | en | ['en', 'error', 'th'] | False |
AbstractGraphListener.on_intermediate_metric | (self, model: Model, metric: MetricData) |
Reports the latest intermediate metric of a trainning graph.
|
Reports the latest intermediate metric of a trainning graph.
| def on_intermediate_metric(self, model: Model, metric: MetricData) -> None:
"""
Reports the latest intermediate metric of a trainning graph.
"""
pass | [
"def",
"on_intermediate_metric",
"(",
"self",
",",
"model",
":",
"Model",
",",
"metric",
":",
"MetricData",
")",
"->",
"None",
":",
"pass"
] | [
51,
4
] | [
55,
12
] | python | en | ['en', 'error', 'th'] | False |
AbstractGraphListener.on_training_end | (self, model: Model, success: bool) |
Reports either a graph is fully trained or the training process has failed.
|
Reports either a graph is fully trained or the training process has failed.
| def on_training_end(self, model: Model, success: bool) -> None:
"""
Reports either a graph is fully trained or the training process has failed.
"""
pass | [
"def",
"on_training_end",
"(",
"self",
",",
"model",
":",
"Model",
",",
"success",
":",
"bool",
")",
"->",
"None",
":",
"pass"
] | [
58,
4
] | [
62,
12
] | python | en | ['en', 'error', 'th'] | False |
AbstractExecutionEngine.submit_models | (self, *models: Model) |
Submit models to NNI.
This method is supposed to call something like `nni.Advisor.create_trial_job(graph_data)`.
|
Submit models to NNI. | def submit_models(self, *models: Model) -> None:
"""
Submit models to NNI.
This method is supposed to call something like `nni.Advisor.create_trial_job(graph_data)`.
"""
raise NotImplementedError | [
"def",
"submit_models",
"(",
"self",
",",
"*",
"models",
":",
"Model",
")",
"->",
"None",
":",
"raise",
"NotImplementedError"
] | [
98,
4
] | [
104,
33
] | python | en | ['en', 'error', 'th'] | False |
AbstractExecutionEngine.list_models | (self) |
Get all models in submitted.
Execution engine should store a copy of models that have been submitted and return a list of copies in this method.
|
Get all models in submitted. | def list_models(self) -> Iterable[Model]:
"""
Get all models in submitted.
Execution engine should store a copy of models that have been submitted and return a list of copies in this method.
"""
raise NotImplementedError | [
"def",
"list_models",
"(",
"self",
")",
"->",
"Iterable",
"[",
"Model",
"]",
":",
"raise",
"NotImplementedError"
] | [
107,
4
] | [
113,
33
] | python | en | ['en', 'error', 'th'] | False |
AbstractExecutionEngine.query_available_resource | (self) |
Returns information of all idle workers.
If no details are available, this may returns a list of "empty" objects, reporting the number of idle workers.
Could be left unimplemented for first iteration.
|
Returns information of all idle workers.
If no details are available, this may returns a list of "empty" objects, reporting the number of idle workers. | def query_available_resource(self) -> Union[List[WorkerInfo], int]:
"""
Returns information of all idle workers.
If no details are available, this may returns a list of "empty" objects, reporting the number of idle workers.
Could be left unimplemented for first iteration.
"""
... | [
"def",
"query_available_resource",
"(",
"self",
")",
"->",
"Union",
"[",
"List",
"[",
"WorkerInfo",
"]",
",",
"int",
"]",
":",
"raise",
"NotImplementedError"
] | [
116,
4
] | [
123,
33
] | python | en | ['en', 'error', 'th'] | False |
AbstractExecutionEngine.budget_exhausted | (self) |
Check whether user configured max trial number or max execution duration has been reached
|
Check whether user configured max trial number or max execution duration has been reached
| def budget_exhausted(self) -> bool:
"""
Check whether user configured max trial number or max execution duration has been reached
"""
raise NotImplementedError | [
"def",
"budget_exhausted",
"(",
"self",
")",
"->",
"bool",
":",
"raise",
"NotImplementedError"
] | [
126,
4
] | [
130,
33
] | python | en | ['en', 'error', 'th'] | False |
AbstractExecutionEngine.register_graph_listener | (self, listener: AbstractGraphListener) |
Register a listener to receive graph events.
Could be left unimplemented for first iteration.
|
Register a listener to receive graph events. | def register_graph_listener(self, listener: AbstractGraphListener) -> None:
"""
Register a listener to receive graph events.
Could be left unimplemented for first iteration.
"""
raise NotImplementedError | [
"def",
"register_graph_listener",
"(",
"self",
",",
"listener",
":",
"AbstractGraphListener",
")",
"->",
"None",
":",
"raise",
"NotImplementedError"
] | [
133,
4
] | [
139,
33
] | python | en | ['en', 'error', 'th'] | False |
AbstractExecutionEngine.trial_execute_graph | (cls) |
Train graph and returns its metrics, in a separate trial process.
Each call to `nni.Advisor.create_trial_job(graph_data)` will eventually invoke this method.
Because this method will be invoked in trial process on training platform,
it has different context from other methods and has ... |
Train graph and returns its metrics, in a separate trial process. | def trial_execute_graph(cls) -> MetricData:
"""
Train graph and returns its metrics, in a separate trial process.
Each call to `nni.Advisor.create_trial_job(graph_data)` will eventually invoke this method.
Because this method will be invoked in trial process on training platform,
... | [
"def",
"trial_execute_graph",
"(",
"cls",
")",
"->",
"MetricData",
":",
"raise",
"NotImplementedError"
] | [
142,
4
] | [
152,
33
] | python | en | ['en', 'error', 'th'] | False |
setup_entry | (hass, entry) | Test that setup entry works. | Test that setup entry works. | async def setup_entry(hass, entry):
"""Test that setup entry works."""
with patch.object(DeconzGateway, "async_setup", return_value=True), patch.object(
DeconzGateway, "async_update_device_registry", return_value=True
):
assert await async_setup_entry(hass, entry) is True | [
"async",
"def",
"setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"with",
"patch",
".",
"object",
"(",
"DeconzGateway",
",",
"\"async_setup\"",
",",
"return_value",
"=",
"True",
")",
",",
"patch",
".",
"object",
"(",
"DeconzGateway",
",",
"\"async_update_d... | [
30,
0
] | [
35,
59
] | python | en | ['en', 'en', 'en'] | True |
test_setup_entry_fails | (hass) | Test setup entry fails if deCONZ is not available. | Test setup entry fails if deCONZ is not available. | async def test_setup_entry_fails(hass):
"""Test setup entry fails if deCONZ is not available."""
with patch("pydeconz.DeconzSession.initialize", side_effect=Exception):
await setup_deconz_integration(hass)
assert not hass.data[DECONZ_DOMAIN] | [
"async",
"def",
"test_setup_entry_fails",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"pydeconz.DeconzSession.initialize\"",
",",
"side_effect",
"=",
"Exception",
")",
":",
"await",
"setup_deconz_integration",
"(",
"hass",
")",
"assert",
"not",
"hass",
".",
"da... | [
38,
0
] | [
42,
39
] | python | en | ['en', 'en', 'en'] | True |
test_setup_entry_no_available_bridge | (hass) | Test setup entry fails if deCONZ is not available. | Test setup entry fails if deCONZ is not available. | async def test_setup_entry_no_available_bridge(hass):
"""Test setup entry fails if deCONZ is not available."""
with patch("pydeconz.DeconzSession.initialize", side_effect=asyncio.TimeoutError):
await setup_deconz_integration(hass)
assert not hass.data[DECONZ_DOMAIN] | [
"async",
"def",
"test_setup_entry_no_available_bridge",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"pydeconz.DeconzSession.initialize\"",
",",
"side_effect",
"=",
"asyncio",
".",
"TimeoutError",
")",
":",
"await",
"setup_deconz_integration",
"(",
"hass",
")",
"ass... | [
45,
0
] | [
49,
39
] | python | en | ['en', 'en', 'en'] | True |
test_setup_entry_successful | (hass) | Test setup entry is successful. | Test setup entry is successful. | async def test_setup_entry_successful(hass):
"""Test setup entry is successful."""
config_entry = await setup_deconz_integration(hass)
gateway = get_gateway_from_config_entry(hass, config_entry)
assert hass.data[DECONZ_DOMAIN]
assert gateway.bridgeid in hass.data[DECONZ_DOMAIN]
assert hass.data... | [
"async",
"def",
"test_setup_entry_successful",
"(",
"hass",
")",
":",
"config_entry",
"=",
"await",
"setup_deconz_integration",
"(",
"hass",
")",
"gateway",
"=",
"get_gateway_from_config_entry",
"(",
"hass",
",",
"config_entry",
")",
"assert",
"hass",
".",
"data",
... | [
52,
0
] | [
59,
60
] | 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.