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_track_time_interval | (
hass: HomeAssistant,
action: Callable[..., Union[None, Awaitable]],
interval: timedelta,
) | Add a listener that fires repetitively at every timedelta interval. | Add a listener that fires repetitively at every timedelta interval. | def async_track_time_interval(
hass: HomeAssistant,
action: Callable[..., Union[None, Awaitable]],
interval: timedelta,
) -> CALLBACK_TYPE:
"""Add a listener that fires repetitively at every timedelta interval."""
remove = None
interval_listener_job = None
job = HassJob(action)
def nex... | [
"def",
"async_track_time_interval",
"(",
"hass",
":",
"HomeAssistant",
",",
"action",
":",
"Callable",
"[",
"...",
",",
"Union",
"[",
"None",
",",
"Awaitable",
"]",
"]",
",",
"interval",
":",
"timedelta",
",",
")",
"->",
"CALLBACK_TYPE",
":",
"remove",
"="... | [
1188,
0
] | [
1221,
26
] | python | en | ['en', 'en', 'en'] | True |
async_track_sunrise | (
hass: HomeAssistant, action: Callable[..., None], offset: Optional[timedelta] = None
) | Add a listener that will fire a specified offset from sunrise daily. | Add a listener that will fire a specified offset from sunrise daily. | def async_track_sunrise(
hass: HomeAssistant, action: Callable[..., None], offset: Optional[timedelta] = None
) -> CALLBACK_TYPE:
"""Add a listener that will fire a specified offset from sunrise daily."""
listener = SunListener(hass, HassJob(action), SUN_EVENT_SUNRISE, offset)
listener.async_attach()
... | [
"def",
"async_track_sunrise",
"(",
"hass",
":",
"HomeAssistant",
",",
"action",
":",
"Callable",
"[",
"...",
",",
"None",
"]",
",",
"offset",
":",
"Optional",
"[",
"timedelta",
"]",
"=",
"None",
")",
"->",
"CALLBACK_TYPE",
":",
"listener",
"=",
"SunListene... | [
1289,
0
] | [
1295,
32
] | python | en | ['en', 'en', 'en'] | True |
async_track_sunset | (
hass: HomeAssistant, action: Callable[..., None], offset: Optional[timedelta] = None
) | Add a listener that will fire a specified offset from sunset daily. | Add a listener that will fire a specified offset from sunset daily. | def async_track_sunset(
hass: HomeAssistant, action: Callable[..., None], offset: Optional[timedelta] = None
) -> CALLBACK_TYPE:
"""Add a listener that will fire a specified offset from sunset daily."""
listener = SunListener(hass, HassJob(action), SUN_EVENT_SUNSET, offset)
listener.async_attach()
r... | [
"def",
"async_track_sunset",
"(",
"hass",
":",
"HomeAssistant",
",",
"action",
":",
"Callable",
"[",
"...",
",",
"None",
"]",
",",
"offset",
":",
"Optional",
"[",
"timedelta",
"]",
"=",
"None",
")",
"->",
"CALLBACK_TYPE",
":",
"listener",
"=",
"SunListener... | [
1303,
0
] | [
1309,
32
] | python | en | ['en', 'en', 'en'] | True |
async_track_utc_time_change | (
hass: HomeAssistant,
action: Callable[..., None],
hour: Optional[Any] = None,
minute: Optional[Any] = None,
second: Optional[Any] = None,
local: bool = False,
) | Add a listener that will fire if time matches a pattern. | Add a listener that will fire if time matches a pattern. | def async_track_utc_time_change(
hass: HomeAssistant,
action: Callable[..., None],
hour: Optional[Any] = None,
minute: Optional[Any] = None,
second: Optional[Any] = None,
local: bool = False,
) -> CALLBACK_TYPE:
"""Add a listener that will fire if time matches a pattern."""
job = HassJo... | [
"def",
"async_track_utc_time_change",
"(",
"hass",
":",
"HomeAssistant",
",",
"action",
":",
"Callable",
"[",
"...",
",",
"None",
"]",
",",
"hour",
":",
"Optional",
"[",
"Any",
"]",
"=",
"None",
",",
"minute",
":",
"Optional",
"[",
"Any",
"]",
"=",
"No... | [
1320,
0
] | [
1379,
45
] | python | en | ['en', 'en', 'en'] | True |
async_track_time_change | (
hass: HomeAssistant,
action: Callable[..., None],
hour: Optional[Any] = None,
minute: Optional[Any] = None,
second: Optional[Any] = None,
) | Add a listener that will fire if UTC time matches a pattern. | Add a listener that will fire if UTC time matches a pattern. | def async_track_time_change(
hass: HomeAssistant,
action: Callable[..., None],
hour: Optional[Any] = None,
minute: Optional[Any] = None,
second: Optional[Any] = None,
) -> CALLBACK_TYPE:
"""Add a listener that will fire if UTC time matches a pattern."""
return async_track_utc_time_change(has... | [
"def",
"async_track_time_change",
"(",
"hass",
":",
"HomeAssistant",
",",
"action",
":",
"Callable",
"[",
"...",
",",
"None",
"]",
",",
"hour",
":",
"Optional",
"[",
"Any",
"]",
"=",
"None",
",",
"minute",
":",
"Optional",
"[",
"Any",
"]",
"=",
"None",... | [
1387,
0
] | [
1395,
86
] | python | en | ['en', 'en', 'en'] | True |
process_state_match | (
parameter: Union[None, str, Iterable[str]]
) | Convert parameter to function that matches input against parameter. | Convert parameter to function that matches input against parameter. | def process_state_match(
parameter: Union[None, str, Iterable[str]]
) -> Callable[[str], bool]:
"""Convert parameter to function that matches input against parameter."""
if parameter is None or parameter == MATCH_ALL:
return lambda _: True
if isinstance(parameter, str) or not hasattr(parameter,... | [
"def",
"process_state_match",
"(",
"parameter",
":",
"Union",
"[",
"None",
",",
"str",
",",
"Iterable",
"[",
"str",
"]",
"]",
")",
"->",
"Callable",
"[",
"[",
"str",
"]",
",",
"bool",
"]",
":",
"if",
"parameter",
"is",
"None",
"or",
"parameter",
"=="... | [
1401,
0
] | [
1412,
47
] | python | en | ['en', 'en', 'en'] | True |
_entities_domains_from_render_infos | (
render_infos: Iterable[RenderInfo],
) | Combine from multiple RenderInfo. | Combine from multiple RenderInfo. | def _entities_domains_from_render_infos(
render_infos: Iterable[RenderInfo],
) -> Tuple[Set, Set]:
"""Combine from multiple RenderInfo."""
entities = set()
domains = set()
for render_info in render_infos:
if render_info.entities:
entities.update(render_info.entities)
if ... | [
"def",
"_entities_domains_from_render_infos",
"(",
"render_infos",
":",
"Iterable",
"[",
"RenderInfo",
"]",
",",
")",
"->",
"Tuple",
"[",
"Set",
",",
"Set",
"]",
":",
"entities",
"=",
"set",
"(",
")",
"domains",
"=",
"set",
"(",
")",
"for",
"render_info",
... | [
1416,
0
] | [
1430,
28
] | python | en | ['en', 'nl', 'en'] | True |
_render_infos_needs_all_listener | (render_infos: Iterable[RenderInfo]) | Determine if an all listener is needed from RenderInfo. | Determine if an all listener is needed from RenderInfo. | def _render_infos_needs_all_listener(render_infos: Iterable[RenderInfo]) -> bool:
"""Determine if an all listener is needed from RenderInfo."""
for render_info in render_infos:
# Tracking all states
if render_info.all_states or render_info.all_states_lifecycle:
return True
#... | [
"def",
"_render_infos_needs_all_listener",
"(",
"render_infos",
":",
"Iterable",
"[",
"RenderInfo",
"]",
")",
"->",
"bool",
":",
"for",
"render_info",
"in",
"render_infos",
":",
"# Tracking all states",
"if",
"render_info",
".",
"all_states",
"or",
"render_info",
".... | [
1434,
0
] | [
1447,
16
] | python | en | ['en', 'en', 'en'] | True |
_render_infos_to_track_states | (render_infos: Iterable[RenderInfo]) | Create a TrackStates dataclass from the latest RenderInfo. | Create a TrackStates dataclass from the latest RenderInfo. | def _render_infos_to_track_states(render_infos: Iterable[RenderInfo]) -> TrackStates:
"""Create a TrackStates dataclass from the latest RenderInfo."""
if _render_infos_needs_all_listener(render_infos):
return TrackStates(True, set(), set())
return TrackStates(False, *_entities_domains_from_render_i... | [
"def",
"_render_infos_to_track_states",
"(",
"render_infos",
":",
"Iterable",
"[",
"RenderInfo",
"]",
")",
"->",
"TrackStates",
":",
"if",
"_render_infos_needs_all_listener",
"(",
"render_infos",
")",
":",
"return",
"TrackStates",
"(",
"True",
",",
"set",
"(",
")"... | [
1451,
0
] | [
1456,
81
] | python | en | ['en', 'en', 'en'] | True |
_event_triggers_rerender | (event: Event, info: RenderInfo) | Determine if a template should be re-rendered from an event. | Determine if a template should be re-rendered from an event. | def _event_triggers_rerender(event: Event, info: RenderInfo) -> bool:
"""Determine if a template should be re-rendered from an event."""
entity_id = event.data.get(ATTR_ENTITY_ID)
if info.filter(entity_id):
return True
if (
event.data.get("new_state") is not None
and event.data... | [
"def",
"_event_triggers_rerender",
"(",
"event",
":",
"Event",
",",
"info",
":",
"RenderInfo",
")",
"->",
"bool",
":",
"entity_id",
"=",
"event",
".",
"data",
".",
"get",
"(",
"ATTR_ENTITY_ID",
")",
"if",
"info",
".",
"filter",
"(",
"entity_id",
")",
":"... | [
1460,
0
] | [
1473,
49
] | python | en | ['en', 'en', 'en'] | True |
_rate_limit_for_event | (
event: Event, info: RenderInfo, track_template_: TrackTemplate
) | Determine the rate limit for an event. | Determine the rate limit for an event. | def _rate_limit_for_event(
event: Event, info: RenderInfo, track_template_: TrackTemplate
) -> Optional[timedelta]:
"""Determine the rate limit for an event."""
entity_id = event.data.get(ATTR_ENTITY_ID)
# Specifically referenced entities are excluded
# from the rate limit
if entity_id in info.... | [
"def",
"_rate_limit_for_event",
"(",
"event",
":",
"Event",
",",
"info",
":",
"RenderInfo",
",",
"track_template_",
":",
"TrackTemplate",
")",
"->",
"Optional",
"[",
"timedelta",
"]",
":",
"entity_id",
"=",
"event",
".",
"data",
".",
"get",
"(",
"ATTR_ENTITY... | [
1477,
0
] | [
1492,
21
] | python | en | ['en', 'en', 'en'] | True |
_suppress_domain_all_in_render_info | (render_info: RenderInfo) | Remove the domains and all_states from render info during a ratelimit. | Remove the domains and all_states from render info during a ratelimit. | def _suppress_domain_all_in_render_info(render_info: RenderInfo) -> RenderInfo:
"""Remove the domains and all_states from render info during a ratelimit."""
rate_limited_render_info = copy.copy(render_info)
rate_limited_render_info.all_states = False
rate_limited_render_info.all_states_lifecycle = False... | [
"def",
"_suppress_domain_all_in_render_info",
"(",
"render_info",
":",
"RenderInfo",
")",
"->",
"RenderInfo",
":",
"rate_limited_render_info",
"=",
"copy",
".",
"copy",
"(",
"render_info",
")",
"rate_limited_render_info",
".",
"all_states",
"=",
"False",
"rate_limited_r... | [
1495,
0
] | [
1502,
35
] | python | en | ['en', 'en', 'en'] | True |
_TrackStateChangeFiltered.__init__ | (
self,
hass: HomeAssistant,
track_states: TrackStates,
action: Callable[[Event], Any],
) | Handle removal / refresh of tracker init. | Handle removal / refresh of tracker init. | def __init__(
self,
hass: HomeAssistant,
track_states: TrackStates,
action: Callable[[Event], Any],
):
"""Handle removal / refresh of tracker init."""
self.hass = hass
self._action = action
self._listeners: Dict[str, Callable] = {}
self._last_t... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"track_states",
":",
"TrackStates",
",",
"action",
":",
"Callable",
"[",
"[",
"Event",
"]",
",",
"Any",
"]",
",",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"_actio... | [
493,
4
] | [
503,
59
] | python | en | ['en', 'en', 'en'] | True |
_TrackStateChangeFiltered.async_setup | (self) | Create listeners to track states. | Create listeners to track states. | def async_setup(self) -> None:
"""Create listeners to track states."""
track_states = self._last_track_states
if (
not track_states.all_states
and not track_states.domains
and not track_states.entities
):
return
if track_states.al... | [
"def",
"async_setup",
"(",
"self",
")",
"->",
"None",
":",
"track_states",
"=",
"self",
".",
"_last_track_states",
"if",
"(",
"not",
"track_states",
".",
"all_states",
"and",
"not",
"track_states",
".",
"domains",
"and",
"not",
"track_states",
".",
"entities",... | [
506,
4
] | [
522,
82
] | python | en | ['en', 'en', 'en'] | True |
_TrackStateChangeFiltered.listeners | (self) | State changes that will cause a re-render. | State changes that will cause a re-render. | def listeners(self) -> Dict:
"""State changes that will cause a re-render."""
track_states = self._last_track_states
return {
_ALL_LISTENER: track_states.all_states,
_ENTITIES_LISTENER: track_states.entities,
_DOMAINS_LISTENER: track_states.domains,
} | [
"def",
"listeners",
"(",
"self",
")",
"->",
"Dict",
":",
"track_states",
"=",
"self",
".",
"_last_track_states",
"return",
"{",
"_ALL_LISTENER",
":",
"track_states",
".",
"all_states",
",",
"_ENTITIES_LISTENER",
":",
"track_states",
".",
"entities",
",",
"_DOMAI... | [
525,
4
] | [
532,
9
] | python | en | ['en', 'en', 'en'] | True |
_TrackStateChangeFiltered.async_update_listeners | (self, new_track_states: TrackStates) | Update the listeners based on the new TrackStates. | Update the listeners based on the new TrackStates. | def async_update_listeners(self, new_track_states: TrackStates) -> None:
"""Update the listeners based on the new TrackStates."""
last_track_states = self._last_track_states
self._last_track_states = new_track_states
had_all_listener = last_track_states.all_states
if new_track_... | [
"def",
"async_update_listeners",
"(",
"self",
",",
"new_track_states",
":",
"TrackStates",
")",
"->",
"None",
":",
"last_track_states",
"=",
"self",
".",
"_last_track_states",
"self",
".",
"_last_track_states",
"=",
"new_track_states",
"had_all_listener",
"=",
"last_t... | [
535,
4
] | [
568,
13
] | python | en | ['en', 'en', 'en'] | True |
_TrackStateChangeFiltered.async_remove | (self) | Cancel the listeners. | Cancel the listeners. | def async_remove(self) -> None:
"""Cancel the listeners."""
for key in list(self._listeners):
self._listeners.pop(key)() | [
"def",
"async_remove",
"(",
"self",
")",
"->",
"None",
":",
"for",
"key",
"in",
"list",
"(",
"self",
".",
"_listeners",
")",
":",
"self",
".",
"_listeners",
".",
"pop",
"(",
"key",
")",
"(",
")"
] | [
571,
4
] | [
574,
38
] | python | en | ['en', 'en', 'en'] | True |
_TrackTemplateResultInfo.__init__ | (
self,
hass: HomeAssistant,
track_templates: Iterable[TrackTemplate],
action: Callable,
) | Handle removal / refresh of tracker init. | Handle removal / refresh of tracker init. | def __init__(
self,
hass: HomeAssistant,
track_templates: Iterable[TrackTemplate],
action: Callable,
):
"""Handle removal / refresh of tracker init."""
self.hass = hass
self._job = HassJob(action)
for track_template_ in track_templates:
tr... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"track_templates",
":",
"Iterable",
"[",
"TrackTemplate",
"]",
",",
"action",
":",
"Callable",
",",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"_job",
"=",
"HassJob",
... | [
735,
4
] | [
754,
59
] | python | en | ['en', 'en', 'en'] | True |
_TrackTemplateResultInfo.async_setup | (self, raise_on_template_error: bool) | Activation of template tracking. | Activation of template tracking. | def async_setup(self, raise_on_template_error: bool) -> None:
"""Activation of template tracking."""
for track_template_ in self._track_templates:
template = track_template_.template
variables = track_template_.variables
self._info[template] = info = template.async_re... | [
"def",
"async_setup",
"(",
"self",
",",
"raise_on_template_error",
":",
"bool",
")",
"->",
"None",
":",
"for",
"track_template_",
"in",
"self",
".",
"_track_templates",
":",
"template",
"=",
"track_template_",
".",
"template",
"variables",
"=",
"track_template_",
... | [
756,
4
] | [
780,
9
] | python | en | ['en', 'en', 'en'] | True |
_TrackTemplateResultInfo.listeners | (self) | State changes that will cause a re-render. | State changes that will cause a re-render. | def listeners(self) -> Dict:
"""State changes that will cause a re-render."""
assert self._track_state_changes
return {
**self._track_state_changes.listeners,
"time": bool(self._time_listeners),
} | [
"def",
"listeners",
"(",
"self",
")",
"->",
"Dict",
":",
"assert",
"self",
".",
"_track_state_changes",
"return",
"{",
"*",
"*",
"self",
".",
"_track_state_changes",
".",
"listeners",
",",
"\"time\"",
":",
"bool",
"(",
"self",
".",
"_time_listeners",
")",
... | [
783,
4
] | [
789,
9
] | python | en | ['en', 'en', 'en'] | True |
_TrackTemplateResultInfo.async_remove | (self) | Cancel the listener. | Cancel the listener. | def async_remove(self) -> None:
"""Cancel the listener."""
assert self._track_state_changes
self._track_state_changes.async_remove()
self._rate_limit.async_remove()
for template in list(self._time_listeners):
self._time_listeners.pop(template)() | [
"def",
"async_remove",
"(",
"self",
")",
"->",
"None",
":",
"assert",
"self",
".",
"_track_state_changes",
"self",
".",
"_track_state_changes",
".",
"async_remove",
"(",
")",
"self",
".",
"_rate_limit",
".",
"async_remove",
"(",
")",
"for",
"template",
"in",
... | [
822,
4
] | [
828,
48
] | python | en | ['en', 'en', 'en'] | True |
_TrackTemplateResultInfo.async_refresh | (self) | Force recalculate the template. | Force recalculate the template. | def async_refresh(self) -> None:
"""Force recalculate the template."""
self._refresh(None) | [
"def",
"async_refresh",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_refresh",
"(",
"None",
")"
] | [
831,
4
] | [
833,
27
] | python | en | ['en', 'en', 'en'] | True |
_TrackTemplateResultInfo._render_template_if_ready | (
self,
track_template_: TrackTemplate,
now: datetime,
event: Optional[Event],
) | Re-render the template if conditions match.
Returns False if the template was not be re-rendered
Returns True if the template re-rendered and did not
change.
Returns TrackTemplateResult if the template re-render
generates a new result.
| Re-render the template if conditions match. | def _render_template_if_ready(
self,
track_template_: TrackTemplate,
now: datetime,
event: Optional[Event],
) -> Union[bool, TrackTemplateResult]:
"""Re-render the template if conditions match.
Returns False if the template was not be re-rendered
Returns Tru... | [
"def",
"_render_template_if_ready",
"(",
"self",
",",
"track_template_",
":",
"TrackTemplate",
",",
"now",
":",
"datetime",
",",
"event",
":",
"Optional",
"[",
"Event",
"]",
",",
")",
"->",
"Union",
"[",
"bool",
",",
"TrackTemplateResult",
"]",
":",
"templat... | [
835,
4
] | [
897,
65
] | python | en | ['en', 'en', 'en'] | True |
_TrackTemplateResultInfo._refresh | (
self,
event: Optional[Event],
track_templates: Optional[Iterable[TrackTemplate]] = None,
replayed: Optional[bool] = False,
) | Refresh the template.
The event is the state_changed event that caused the refresh
to be considered.
track_templates is an optional list of TrackTemplate objects
to refresh. If not provided, all tracked templates will be
considered.
replayed is True if the event is be... | Refresh the template. | def _refresh(
self,
event: Optional[Event],
track_templates: Optional[Iterable[TrackTemplate]] = None,
replayed: Optional[bool] = False,
) -> None:
"""Refresh the template.
The event is the state_changed event that caused the refresh
to be considered.
... | [
"def",
"_refresh",
"(",
"self",
",",
"event",
":",
"Optional",
"[",
"Event",
"]",
",",
"track_templates",
":",
"Optional",
"[",
"Iterable",
"[",
"TrackTemplate",
"]",
"]",
"=",
"None",
",",
"replayed",
":",
"Optional",
"[",
"bool",
"]",
"=",
"False",
"... | [
900,
4
] | [
959,
63
] | python | en | ['en', 'en', 'en'] | True |
GaussianProcess_QuasiPeriodicActivity_Shared.convert_val2gp | (self, input_pams) |
:param input_pam: dictonary with the 'physically meaningful' parameters of the GP kernel
:return: dictonary with the parameters to be fed to 'george'
WARNING: this subroutine is HIGHLY specific of your choice of the kernel! I reccomend to
create a new Class with different transformation... |
:param input_pam: dictonary with the 'physically meaningful' parameters of the GP kernel
:return: dictonary with the parameters to be fed to 'george'
WARNING: this subroutine is HIGHLY specific of your choice of the kernel! I reccomend to
create a new Class with different transformation... | def convert_val2gp(self, input_pams):
"""
:param input_pam: dictonary with the 'physically meaningful' parameters of the GP kernel
:return: dictonary with the parameters to be fed to 'george'
WARNING: this subroutine is HIGHLY specific of your choice of the kernel! I reccomend to
... | [
"def",
"convert_val2gp",
"(",
"self",
",",
"input_pams",
")",
":",
"output_pams",
"=",
"np",
".",
"zeros",
"(",
"self",
".",
"n_pams",
",",
"dtype",
"=",
"np",
".",
"double",
")",
"\"\"\" You must check _george_ documentation (and possibily do a lot of testing) to kno... | [
59,
4
] | [
78,
26
] | python | en | ['en', 'error', 'th'] | False |
GaussianProcess_QuasiPeriodicActivity_Shared.convert_gp2val | (self, input_pams) |
:param input_pam: dictonary with the parameters to be fed to 'george'
:return: dictonary with the 'physically meaningful' parameters of the GP kernel
WARNING: this subroutine is HIGHLY specific of your choice of the kernel! I reccomend to
create a new Class with different transformation... |
:param input_pam: dictonary with the parameters to be fed to 'george'
:return: dictonary with the 'physically meaningful' parameters of the GP kernel
WARNING: this subroutine is HIGHLY specific of your choice of the kernel! I reccomend to
create a new Class with different transformation... | def convert_gp2val(self, input_pams):
"""
:param input_pam: dictonary with the parameters to be fed to 'george'
:return: dictonary with the 'physically meaningful' parameters of the GP kernel
WARNING: this subroutine is HIGHLY specific of your choice of the kernel! I reccomend to
... | [
"def",
"convert_gp2val",
"(",
"self",
",",
"input_pams",
")",
":",
"return",
"{",
"'Hamp'",
":",
"np",
".",
"exp",
"(",
"input_pams",
"[",
"self",
".",
"gp_pams_index",
"[",
"'Hamp'",
"]",
"]",
"/",
"2.0",
")",
",",
"'Pdec'",
":",
"np",
".",
"exp",
... | [
80,
4
] | [
93,
9
] | python | en | ['en', 'error', 'th'] | False |
GaussianProcess_QuasiPeriodicActivity_Shared.define_kernel | (self, dataset) | Kernel initialized with fake values... don't worry, they'll be overwritten soon | Kernel initialized with fake values... don't worry, they'll be overwritten soon | def define_kernel(self, dataset):
gp_pams = np.ones(self.n_pams)
""" Kernel initialized with fake values... don't worry, they'll be overwritten soon"""
kernel = np.exp(gp_pams[0]) * \
george.kernels.ExpSquaredKernel(metric=np.exp(gp_pams[1])) * \
geor... | [
"def",
"define_kernel",
"(",
"self",
",",
"dataset",
")",
":",
"gp_pams",
"=",
"np",
".",
"ones",
"(",
"self",
".",
"n_pams",
")",
"kernel",
"=",
"np",
".",
"exp",
"(",
"gp_pams",
"[",
"0",
"]",
")",
"*",
"george",
".",
"kernels",
".",
"ExpSquaredK... | [
104,
4
] | [
136,
14
] | python | en | ['en', 'en', 'en'] | True |
GaussianProcess_QuasiPeriodicActivity_Shared.lnlk_compute | (self) | 2 steps:
1) theta parameters must be converted in physical units (e.g. from logarithmic to linear spaces)
2) physical values must be converted to {\tt george} input parameters
| 2 steps:
1) theta parameters must be converted in physical units (e.g. from logarithmic to linear spaces)
2) physical values must be converted to {\tt george} input parameters
| def lnlk_compute(self):
""" 2 steps:
1) theta parameters must be converted in physical units (e.g. from logarithmic to linear spaces)
2) physical values must be converted to {\tt george} input parameters
"""
self.gp.set_parameter_vector(self.internal_gp_pams)
self.g... | [
"def",
"lnlk_compute",
"(",
"self",
")",
":",
"self",
".",
"gp",
".",
"set_parameter_vector",
"(",
"self",
".",
"internal_gp_pams",
")",
"self",
".",
"gp",
".",
"compute",
"(",
"self",
".",
"internal_dataset",
"[",
"'x0'",
"]",
",",
"self",
".",
"interna... | [
154,
4
] | [
162,
78
] | python | en | ['en', 'sk', 'en'] | False |
async_setup_entry | (hass, config_entry, async_add_entities) | Load Tradfri switches based on a config entry. | Load Tradfri switches based on a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Load Tradfri switches based on a config entry."""
gateway_id = config_entry.data[CONF_GATEWAY_ID]
tradfri_data = hass.data[DOMAIN][config_entry.entry_id]
api = tradfri_data[KEY_API]
devices = tradfri_data[DEVICES]
switches ... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"gateway_id",
"=",
"config_entry",
".",
"data",
"[",
"CONF_GATEWAY_ID",
"]",
"tradfri_data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_... | [
7,
0
] | [
18,
9
] | python | en | ['en', 'en', 'en'] | True |
TradfriSwitch.__init__ | (self, device, api, gateway_id) | Initialize a switch. | Initialize a switch. | def __init__(self, device, api, gateway_id):
"""Initialize a switch."""
super().__init__(device, api, gateway_id)
self._unique_id = f"{gateway_id}-{device.id}" | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"api",
",",
"gateway_id",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"device",
",",
"api",
",",
"gateway_id",
")",
"self",
".",
"_unique_id",
"=",
"f\"{gateway_id}-{device.id}\""
] | [
24,
4
] | [
27,
53
] | python | en | ['en', 'pl', 'en'] | True |
TradfriSwitch._refresh | (self, device) | Refresh the switch data. | Refresh the switch data. | def _refresh(self, device):
"""Refresh the switch data."""
super()._refresh(device)
# Caching of switch control and switch object
self._device_control = device.socket_control
self._device_data = device.socket_control.sockets[0] | [
"def",
"_refresh",
"(",
"self",
",",
"device",
")",
":",
"super",
"(",
")",
".",
"_refresh",
"(",
"device",
")",
"# Caching of switch control and switch object",
"self",
".",
"_device_control",
"=",
"device",
".",
"socket_control",
"self",
".",
"_device_data",
"... | [
29,
4
] | [
35,
60
] | python | en | ['en', 'en', 'en'] | True |
TradfriSwitch.is_on | (self) | Return true if switch is on. | Return true if switch is on. | def is_on(self):
"""Return true if switch is on."""
return self._device_data.state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_data",
".",
"state"
] | [
38,
4
] | [
40,
38
] | python | en | ['en', 'fy', 'en'] | True |
TradfriSwitch.async_turn_off | (self, **kwargs) | Instruct the switch to turn off. | Instruct the switch to turn off. | async def async_turn_off(self, **kwargs):
"""Instruct the switch to turn off."""
await self._api(self._device_control.set_state(False)) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_api",
"(",
"self",
".",
"_device_control",
".",
"set_state",
"(",
"False",
")",
")"
] | [
42,
4
] | [
44,
62
] | python | en | ['en', 'en', 'en'] | True |
TradfriSwitch.async_turn_on | (self, **kwargs) | Instruct the switch to turn on. | Instruct the switch to turn on. | async def async_turn_on(self, **kwargs):
"""Instruct the switch to turn on."""
await self._api(self._device_control.set_state(True)) | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_api",
"(",
"self",
".",
"_device_control",
".",
"set_state",
"(",
"True",
")",
")"
] | [
46,
4
] | [
48,
61
] | python | en | ['en', 'en', 'en'] | True |
EcobeeFlowHandler.__init__ | (self) | Initialize the ecobee flow. | Initialize the ecobee flow. | def __init__(self):
"""Initialize the ecobee flow."""
self._ecobee = None | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"_ecobee",
"=",
"None"
] | [
23,
4
] | [
25,
27
] | python | en | ['en', 'en', 'en'] | True |
EcobeeFlowHandler.async_step_user | (self, user_input=None) | Handle a flow initiated by the user. | Handle a flow initiated by the user. | async def async_step_user(self, user_input=None):
"""Handle a flow initiated by the user."""
if self._async_current_entries():
# Config entry already exists, only one allowed.
return self.async_abort(reason="single_instance_allowed")
errors = {}
stored_api_key = ... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"self",
".",
"_async_current_entries",
"(",
")",
":",
"# Config entry already exists, only one allowed.",
"return",
"self",
".",
"async_abort",
"(",
"reason",
"=",
"\"s... | [
27,
4
] | [
55,
9
] | python | en | ['en', 'en', 'en'] | True |
EcobeeFlowHandler.async_step_authorize | (self, user_input=None) | Present the user with the PIN so that the app can be authorized on ecobee.com. | Present the user with the PIN so that the app can be authorized on ecobee.com. | async def async_step_authorize(self, user_input=None):
"""Present the user with the PIN so that the app can be authorized on ecobee.com."""
errors = {}
if user_input is not None:
# Attempt to obtain tokens from ecobee and finish the flow.
if await self.hass.async_add_exe... | [
"async",
"def",
"async_step_authorize",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"# Attempt to obtain tokens from ecobee and finish the flow.",
"if",
"await",
"self",
".",
"hass",... | [
57,
4
] | [
76,
9
] | python | en | ['en', 'en', 'en'] | True |
EcobeeFlowHandler.async_step_import | (self, import_data) |
Import ecobee config from configuration.yaml.
Triggered by async_setup only if a config entry doesn't already exist.
If ecobee.conf exists, we will attempt to validate the credentials
and create an entry if valid. Otherwise, we will delegate to the user
step so that the user ca... |
Import ecobee config from configuration.yaml. | async def async_step_import(self, import_data):
"""
Import ecobee config from configuration.yaml.
Triggered by async_setup only if a config entry doesn't already exist.
If ecobee.conf exists, we will attempt to validate the credentials
and create an entry if valid. Otherwise, we... | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"import_data",
")",
":",
"try",
":",
"legacy_config",
"=",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"load_json",
",",
"self",
".",
"hass",
".",
"config",
".",
"path",
"(",
"ECO... | [
78,
4
] | [
122,
9
] | python | en | ['en', 'error', 'th'] | False |
async_describe_on_off_states | (
hass: HomeAssistantType, registry: GroupIntegrationRegistry
) | Describe group on off states. | Describe group on off states. | def async_describe_on_off_states(
hass: HomeAssistantType, registry: GroupIntegrationRegistry
) -> None:
"""Describe group on off states."""
registry.on_off_states(
{
STATE_ALARM_ARMED_AWAY,
STATE_ALARM_ARMED_CUSTOM_BYPASS,
STATE_ALARM_ARMED_HOME,
STAT... | [
"def",
"async_describe_on_off_states",
"(",
"hass",
":",
"HomeAssistantType",
",",
"registry",
":",
"GroupIntegrationRegistry",
")",
"->",
"None",
":",
"registry",
".",
"on_off_states",
"(",
"{",
"STATE_ALARM_ARMED_AWAY",
",",
"STATE_ALARM_ARMED_CUSTOM_BYPASS",
",",
"ST... | [
17,
0
] | [
30,
5
] | python | en | ['en', 'en', 'en'] | True |
init_config_flow | (hass, side_effect=None) | Init a configuration flow. | Init a configuration flow. | def init_config_flow(hass, side_effect=None):
"""Init a configuration flow."""
flow = config_flow.FlowHandler()
flow.hass = hass
if side_effect:
flow._get_auth_url = Mock(side_effect=side_effect)
return flow | [
"def",
"init_config_flow",
"(",
"hass",
",",
"side_effect",
"=",
"None",
")",
":",
"flow",
"=",
"config_flow",
".",
"FlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"if",
"side_effect",
":",
"flow",
".",
"_get_auth_url",
"=",
"Mock",
"(",
"side... | [
21,
0
] | [
27,
15
] | python | en | ['es', 'fr', 'en'] | False |
supports_local_api | () | Set TelldusLive supports_local_api. | Set TelldusLive supports_local_api. | def supports_local_api():
"""Set TelldusLive supports_local_api."""
return True | [
"def",
"supports_local_api",
"(",
")",
":",
"return",
"True"
] | [
31,
0
] | [
33,
15
] | python | bg-Latn | ['et', 'bg-Latn', 'en'] | False |
authorize | () | Set TelldusLive authorize. | Set TelldusLive authorize. | def authorize():
"""Set TelldusLive authorize."""
return True | [
"def",
"authorize",
"(",
")",
":",
"return",
"True"
] | [
37,
0
] | [
39,
15
] | python | de | ['de', 'hu', 'en'] | False |
mock_tellduslive | (supports_local_api, authorize) | Mock tellduslive. | Mock tellduslive. | def mock_tellduslive(supports_local_api, authorize):
"""Mock tellduslive."""
with patch(
"homeassistant.components.tellduslive.config_flow.Session"
) as Session, patch(
"homeassistant.components.tellduslive.config_flow.supports_local_api"
) as tellduslive_supports_local_api:
tell... | [
"def",
"mock_tellduslive",
"(",
"supports_local_api",
",",
"authorize",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.tellduslive.config_flow.Session\"",
")",
"as",
"Session",
",",
"patch",
"(",
"\"homeassistant.components.tellduslive.config_flow.supports_local_api\... | [
43,
0
] | [
55,
53
] | python | en | ['et', 'hu', 'en'] | False |
test_abort_if_already_setup | (hass) | Test we abort if TelldusLive is already setup. | Test we abort if TelldusLive is already setup. | async def test_abort_if_already_setup(hass):
"""Test we abort if TelldusLive is already setup."""
flow = init_config_flow(hass)
with patch.object(hass.config_entries, "async_entries", return_value=[{}]):
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_... | [
"async",
"def",
"test_abort_if_already_setup",
"(",
"hass",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"with",
"patch",
".",
"object",
"(",
"hass",
".",
"config_entries",
",",
"\"async_entries\"",
",",
"return_value",
"=",
"[",
"{",
"}",
"]... | [
58,
0
] | [
70,
46
] | python | en | ['en', 'zu', 'en'] | True |
test_full_flow_implementation | (hass, mock_tellduslive) | Test registering an implementation and finishing flow works. | Test registering an implementation and finishing flow works. | async def test_full_flow_implementation(hass, mock_tellduslive):
"""Test registering an implementation and finishing flow works."""
flow = init_config_flow(hass)
flow.context = {"source": SOURCE_DISCOVERY}
result = await flow.async_step_discovery(["localhost", "tellstick"])
assert result["type"] == ... | [
"async",
"def",
"test_full_flow_implementation",
"(",
"hass",
",",
"mock_tellduslive",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"flow",
".",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_DISCOVERY",
"}",
"result",
"=",
"await",
"flow",
".... | [
73,
0
] | [
99,
79
] | python | en | ['en', 'en', 'en'] | True |
test_step_import | (hass, mock_tellduslive) | Test that we trigger auth when configuring from import. | Test that we trigger auth when configuring from import. | async def test_step_import(hass, mock_tellduslive):
"""Test that we trigger auth when configuring from import."""
flow = init_config_flow(hass)
result = await flow.async_step_import({CONF_HOST: DOMAIN, KEY_SCAN_INTERVAL: 0})
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["s... | [
"async",
"def",
"test_step_import",
"(",
"hass",
",",
"mock_tellduslive",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"result",
"=",
"await",
"flow",
".",
"async_step_import",
"(",
"{",
"CONF_HOST",
":",
"DOMAIN",
",",
"KEY_SCAN_INTERVAL",
":"... | [
102,
0
] | [
108,
38
] | python | en | ['en', 'en', 'en'] | True |
test_step_import_add_host | (hass, mock_tellduslive) | Test that we add host and trigger user when configuring from import. | Test that we add host and trigger user when configuring from import. | async def test_step_import_add_host(hass, mock_tellduslive):
"""Test that we add host and trigger user when configuring from import."""
flow = init_config_flow(hass)
result = await flow.async_step_import(
{CONF_HOST: "localhost", KEY_SCAN_INTERVAL: 0}
)
assert result["type"] == data_entry_f... | [
"async",
"def",
"test_step_import_add_host",
"(",
"hass",
",",
"mock_tellduslive",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"result",
"=",
"await",
"flow",
".",
"async_step_import",
"(",
"{",
"CONF_HOST",
":",
"\"localhost\"",
",",
"KEY_SCAN_... | [
111,
0
] | [
119,
38
] | python | en | ['en', 'en', 'en'] | True |
test_step_import_no_config_file | (hass, mock_tellduslive) | Test that we trigger user with no config_file configuring from import. | Test that we trigger user with no config_file configuring from import. | async def test_step_import_no_config_file(hass, mock_tellduslive):
"""Test that we trigger user with no config_file configuring from import."""
flow = init_config_flow(hass)
result = await flow.async_step_import(
{CONF_HOST: "localhost", KEY_SCAN_INTERVAL: 0}
)
assert result["type"] == data... | [
"async",
"def",
"test_step_import_no_config_file",
"(",
"hass",
",",
"mock_tellduslive",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"result",
"=",
"await",
"flow",
".",
"async_step_import",
"(",
"{",
"CONF_HOST",
":",
"\"localhost\"",
",",
"KEY... | [
122,
0
] | [
130,
38
] | python | en | ['en', 'en', 'en'] | True |
test_step_import_load_json_matching_host | (hass, mock_tellduslive) | Test that we add host and trigger user when configuring from import. | Test that we add host and trigger user when configuring from import. | async def test_step_import_load_json_matching_host(hass, mock_tellduslive):
"""Test that we add host and trigger user when configuring from import."""
flow = init_config_flow(hass)
with patch(
"homeassistant.components.tellduslive.config_flow.load_json",
return_value={"tellduslive": {}},
... | [
"async",
"def",
"test_step_import_load_json_matching_host",
"(",
"hass",
",",
"mock_tellduslive",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"with",
"patch",
"(",
"\"homeassistant.components.tellduslive.config_flow.load_json\"",
",",
"return_value",
"=",
... | [
133,
0
] | [
145,
38
] | python | en | ['en', 'en', 'en'] | True |
test_step_import_load_json | (hass, mock_tellduslive) | Test that we create entry when configuring from import. | Test that we create entry when configuring from import. | async def test_step_import_load_json(hass, mock_tellduslive):
"""Test that we create entry when configuring from import."""
flow = init_config_flow(hass)
with patch(
"homeassistant.components.tellduslive.config_flow.load_json",
return_value={"localhost": {}},
), patch("os.path.isfile"):... | [
"async",
"def",
"test_step_import_load_json",
"(",
"hass",
",",
"mock_tellduslive",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"with",
"patch",
"(",
"\"homeassistant.components.tellduslive.config_flow.load_json\"",
",",
"return_value",
"=",
"{",
"\"loc... | [
148,
0
] | [
163,
42
] | python | en | ['en', 'en', 'en'] | True |
test_step_disco_no_local_api | (hass, mock_tellduslive) | Test that we trigger when configuring from discovery, not supporting local api. | Test that we trigger when configuring from discovery, not supporting local api. | async def test_step_disco_no_local_api(hass, mock_tellduslive):
"""Test that we trigger when configuring from discovery, not supporting local api."""
flow = init_config_flow(hass)
flow.context = {"source": SOURCE_DISCOVERY}
result = await flow.async_step_discovery(["localhost", "tellstick"])
assert... | [
"async",
"def",
"test_step_disco_no_local_api",
"(",
"hass",
",",
"mock_tellduslive",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"flow",
".",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_DISCOVERY",
"}",
"result",
"=",
"await",
"flow",
"."... | [
167,
0
] | [
175,
32
] | python | en | ['en', 'en', 'en'] | True |
test_step_auth | (hass, mock_tellduslive) | Test that create cloud entity from auth. | Test that create cloud entity from auth. | async def test_step_auth(hass, mock_tellduslive):
"""Test that create cloud entity from auth."""
flow = init_config_flow(hass)
await flow.async_step_auth()
result = await flow.async_step_auth(["localhost", "tellstick"])
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert re... | [
"async",
"def",
"test_step_auth",
"(",
"hass",
",",
"mock_tellduslive",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"await",
"flow",
".",
"async_step_auth",
"(",
")",
"result",
"=",
"await",
"flow",
".",
"async_step_auth",
"(",
"[",
"\"local... | [
178,
0
] | [
191,
5
] | python | en | ['en', 'en', 'en'] | True |
test_wrong_auth_flow_implementation | (hass, mock_tellduslive) | Test wrong auth. | Test wrong auth. | async def test_wrong_auth_flow_implementation(hass, mock_tellduslive):
"""Test wrong auth."""
flow = init_config_flow(hass)
await flow.async_step_auth()
result = await flow.async_step_auth("")
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "auth"
asser... | [
"async",
"def",
"test_wrong_auth_flow_implementation",
"(",
"hass",
",",
"mock_tellduslive",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"await",
"flow",
".",
"async_step_auth",
"(",
")",
"result",
"=",
"await",
"flow",
".",
"async_step_auth",
"... | [
195,
0
] | [
203,
53
] | python | en | ['en', 'en', 'en'] | True |
test_not_pick_host_if_only_one | (hass, mock_tellduslive) | Test not picking host if we have just one. | Test not picking host if we have just one. | async def test_not_pick_host_if_only_one(hass, mock_tellduslive):
"""Test not picking host if we have just one."""
flow = init_config_flow(hass)
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "auth" | [
"async",
"def",
"test_not_pick_host_if_only_one",
"(",
"hass",
",",
"mock_tellduslive",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"result",
"=",
"await",
"flow",
".",
"async_step_user",
"(",
")",
"assert",
"result",
"[",
"\"type\"",
"]",
"==... | [
206,
0
] | [
212,
38
] | python | en | ['en', 'en', 'en'] | True |
test_abort_if_timeout_generating_auth_url | (hass, mock_tellduslive) | Test abort if generating authorize url timeout. | Test abort if generating authorize url timeout. | async def test_abort_if_timeout_generating_auth_url(hass, mock_tellduslive):
"""Test abort if generating authorize url timeout."""
flow = init_config_flow(hass, side_effect=asyncio.TimeoutError)
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert ... | [
"async",
"def",
"test_abort_if_timeout_generating_auth_url",
"(",
"hass",
",",
"mock_tellduslive",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
",",
"side_effect",
"=",
"asyncio",
".",
"TimeoutError",
")",
"result",
"=",
"await",
"flow",
".",
"async_ste... | [
215,
0
] | [
221,
54
] | python | de | ['de', 'zu', 'en'] | False |
test_abort_no_auth_url | (hass, mock_tellduslive) | Test abort if generating authorize url returns none. | Test abort if generating authorize url returns none. | async def test_abort_no_auth_url(hass, mock_tellduslive):
"""Test abort if generating authorize url returns none."""
flow = init_config_flow(hass)
flow._get_auth_url = Mock(return_value=False)
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
asser... | [
"async",
"def",
"test_abort_no_auth_url",
"(",
"hass",
",",
"mock_tellduslive",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"flow",
".",
"_get_auth_url",
"=",
"Mock",
"(",
"return_value",
"=",
"False",
")",
"result",
"=",
"await",
"flow",
".... | [
224,
0
] | [
231,
51
] | python | en | ['de', 'en', 'en'] | True |
test_abort_if_exception_generating_auth_url | (hass, mock_tellduslive) | Test we abort if generating authorize url blows up. | Test we abort if generating authorize url blows up. | async def test_abort_if_exception_generating_auth_url(hass, mock_tellduslive):
"""Test we abort if generating authorize url blows up."""
flow = init_config_flow(hass, side_effect=ValueError)
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert resu... | [
"async",
"def",
"test_abort_if_exception_generating_auth_url",
"(",
"hass",
",",
"mock_tellduslive",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
",",
"side_effect",
"=",
"ValueError",
")",
"result",
"=",
"await",
"flow",
".",
"async_step_user",
"(",
")... | [
234,
0
] | [
240,
51
] | python | en | ['de', 'en', 'en'] | True |
test_discovery_already_configured | (hass, mock_tellduslive) | Test abort if already configured fires from discovery. | Test abort if already configured fires from discovery. | async def test_discovery_already_configured(hass, mock_tellduslive):
"""Test abort if already configured fires from discovery."""
MockConfigEntry(domain="tellduslive", data={"host": "some-host"}).add_to_hass(hass)
flow = init_config_flow(hass)
flow.context = {"source": SOURCE_DISCOVERY}
with pytest... | [
"async",
"def",
"test_discovery_already_configured",
"(",
"hass",
",",
"mock_tellduslive",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"\"tellduslive\"",
",",
"data",
"=",
"{",
"\"host\"",
":",
"\"some-host\"",
"}",
")",
".",
"add_to_hass",
"(",
"hass",
")"... | [
243,
0
] | [
250,
67
] | python | en | ['en', 'en', 'en'] | True |
get_service | (hass, config, discovery_info=None) | Get the ClickSend notification service. | Get the ClickSend notification service. | def get_service(hass, config, discovery_info=None):
"""Get the ClickSend notification service."""
if not _authenticate(config):
_LOGGER.error("You are not authorized to access ClickSend")
return None
return ClicksendNotificationService(config) | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"not",
"_authenticate",
"(",
"config",
")",
":",
"_LOGGER",
".",
"error",
"(",
"\"You are not authorized to access ClickSend\"",
")",
"return",
"None",
"return"... | [
44,
0
] | [
50,
47
] | python | en | ['en', 'en', 'en'] | True |
_authenticate | (config) | Authenticate with ClickSend. | Authenticate with ClickSend. | def _authenticate(config):
"""Authenticate with ClickSend."""
api_url = f"{BASE_API_URL}/account"
resp = requests.get(
api_url,
headers=HEADERS,
auth=(config.get(CONF_USERNAME), config.get(CONF_API_KEY)),
timeout=TIMEOUT,
)
if resp.status_code != HTTP_OK:
ret... | [
"def",
"_authenticate",
"(",
"config",
")",
":",
"api_url",
"=",
"f\"{BASE_API_URL}/account\"",
"resp",
"=",
"requests",
".",
"get",
"(",
"api_url",
",",
"headers",
"=",
"HEADERS",
",",
"auth",
"=",
"(",
"config",
".",
"get",
"(",
"CONF_USERNAME",
")",
","... | [
100,
0
] | [
113,
15
] | python | en | ['en', 'en', 'en'] | True |
ClicksendNotificationService.__init__ | (self, config) | Initialize the service. | Initialize the service. | def __init__(self, config):
"""Initialize the service."""
self.username = config[CONF_USERNAME]
self.api_key = config[CONF_API_KEY]
self.recipient = config[CONF_RECIPIENT]
self.language = config[CONF_LANGUAGE]
self.voice = config[CONF_VOICE]
self.caller = config.g... | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"username",
"=",
"config",
"[",
"CONF_USERNAME",
"]",
"self",
".",
"api_key",
"=",
"config",
"[",
"CONF_API_KEY",
"]",
"self",
".",
"recipient",
"=",
"config",
"[",
"CONF_RECIPIENT",
"... | [
56,
4
] | [
65,
40
] | python | en | ['en', 'en', 'en'] | True |
ClicksendNotificationService.send_message | (self, message="", **kwargs) | Send a voice call to a user. | Send a voice call to a user. | def send_message(self, message="", **kwargs):
"""Send a voice call to a user."""
data = {
"messages": [
{
"source": "hass.notify",
"from": self.caller,
"to": self.recipient,
"body": message,
... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"\"messages\"",
":",
"[",
"{",
"\"source\"",
":",
"\"hass.notify\"",
",",
"\"from\"",
":",
"self",
".",
"caller",
",",
"\"to\"",
":",
... | [
67,
4
] | [
97,
9
] | python | en | ['en', 'en', 'en'] | True |
is_invalid_auth_code | (http_status_code) | HTTP status codes that mean invalid auth. | HTTP status codes that mean invalid auth. | def is_invalid_auth_code(http_status_code):
"""HTTP status codes that mean invalid auth."""
if http_status_code in (HTTP_UNAUTHORIZED, HTTP_FORBIDDEN):
return True
return False | [
"def",
"is_invalid_auth_code",
"(",
"http_status_code",
")",
":",
"if",
"http_status_code",
"in",
"(",
"HTTP_UNAUTHORIZED",
",",
"HTTP_FORBIDDEN",
")",
":",
"return",
"True",
"return",
"False"
] | [
5,
0
] | [
10,
16
] | python | en | ['en', 'en', 'en'] | True |
percent_conv | (val) | Convert an actual percentage (0.0-1.0) to 0-100 scale. | Convert an actual percentage (0.0-1.0) to 0-100 scale. | def percent_conv(val):
"""Convert an actual percentage (0.0-1.0) to 0-100 scale."""
return round(val * 100.0, 1) | [
"def",
"percent_conv",
"(",
"val",
")",
":",
"return",
"round",
"(",
"val",
"*",
"100.0",
",",
"1",
")"
] | [
13,
0
] | [
15,
32
] | python | en | ['en', 'en', 'en'] | True |
GenerateConfig | (context) | Generates configuration. | Generates configuration. | def GenerateConfig(context):
"""Generates configuration."""
image = ''.join(['https://www.googleapis.com/compute/v1/',
'projects/cos-cloud/global/images/',
context.properties['containerImage']])
default_network = ''.join(['https://www.googleapis.com/compute/v1/projects/',
... | [
"def",
"GenerateConfig",
"(",
"context",
")",
":",
"image",
"=",
"''",
".",
"join",
"(",
"[",
"'https://www.googleapis.com/compute/v1/'",
",",
"'projects/cos-cloud/global/images/'",
",",
"context",
".",
"properties",
"[",
"'containerImage'",
"]",
"]",
")",
"default_... | [
19,
0
] | [
67,
63
] | python | en | ['en', 'la', 'en'] | False |
make_categorical | (corpus) |
terrible : 0.0 < y <= 3.0
okay : 3.0 < y <= 5.0
great : 5.0 < y <= 7.0
amazing : 7.0 < y <= 10.1
:param corpus:
:return:
|
terrible : 0.0 < y <= 3.0
okay : 3.0 < y <= 5.0
great : 5.0 < y <= 7.0
amazing : 7.0 < y <= 10.1
:param corpus:
:return:
| def make_categorical(corpus):
"""
terrible : 0.0 < y <= 3.0
okay : 3.0 < y <= 5.0
great : 5.0 < y <= 7.0
amazing : 7.0 < y <= 10.1
:param corpus:
:return:
"""
return np.digitize(continuous(corpus), [0.0, 3.0, 5.0, 7.0, 10.1]) | [
"def",
"make_categorical",
"(",
"corpus",
")",
":",
"return",
"np",
".",
"digitize",
"(",
"continuous",
"(",
"corpus",
")",
",",
"[",
"0.0",
",",
"3.0",
",",
"5.0",
",",
"7.0",
",",
"10.1",
"]",
")"
] | [
23,
0
] | [
32,
70
] | python | en | ['en', 'error', 'th'] | False |
train_model | (path, model, continuous=True, saveto=None, cv=12) |
Trains model from corpus at specified path; constructing cross-validation
scores using the cv parameter, then fitting the model on the full data and
writing it to disk at the saveto path if specified. Returns the scores.
|
Trains model from corpus at specified path; constructing cross-validation
scores using the cv parameter, then fitting the model on the full data and
writing it to disk at the saveto path if specified. Returns the scores.
| def train_model(path, model, continuous=True, saveto=None, cv=12):
"""
Trains model from corpus at specified path; constructing cross-validation
scores using the cv parameter, then fitting the model on the full data and
writing it to disk at the saveto path if specified. Returns the scores.
"""
... | [
"def",
"train_model",
"(",
"path",
",",
"model",
",",
"continuous",
"=",
"True",
",",
"saveto",
"=",
"None",
",",
"cv",
"=",
"12",
")",
":",
"# Load the corpus data and labels for classification",
"corpus",
"=",
"PickledReviewsReader",
"(",
"path",
")",
"X",
"... | [
35,
0
] | [
62,
17
] | python | en | ['en', 'error', 'th'] | False |
_validate_input | (data: Dict[str, Any]) | Validate the user input allows us to connect. | Validate the user input allows us to connect. | async def _validate_input(data: Dict[str, Any]) -> str:
"""Validate the user input allows us to connect."""
try:
bond = Bond(data[CONF_HOST], data[CONF_ACCESS_TOKEN])
version = await bond.version()
# call to non-version API is needed to validate authentication
await bond.devices... | [
"async",
"def",
"_validate_input",
"(",
"data",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"str",
":",
"try",
":",
"bond",
"=",
"Bond",
"(",
"data",
"[",
"CONF_HOST",
"]",
",",
"data",
"[",
"CONF_ACCESS_TOKEN",
"]",
")",
"version",
"=",
"... | [
27,
0
] | [
50,
18
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_zeroconf | (
self, discovery_info: Optional[Dict[str, Any]] = None
) | Handle a flow initialized by zeroconf discovery. | Handle a flow initialized by zeroconf discovery. | async def async_step_zeroconf(
self, discovery_info: Optional[Dict[str, Any]] = None
) -> Dict[str, Any]:
"""Handle a flow initialized by zeroconf discovery."""
name: str = discovery_info[CONF_NAME]
host: str = discovery_info[CONF_HOST]
bond_id = name.partition(".")[0]
... | [
"async",
"def",
"async_step_zeroconf",
"(",
"self",
",",
"discovery_info",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"name",
":",
"str",
"=",
"discovery_info",
"[... | [
61,
4
] | [
78,
46
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_confirm | (
self, user_input: Dict[str, Any] = None
) | Handle confirmation flow for discovered bond hub. | Handle confirmation flow for discovered bond hub. | async def async_step_confirm(
self, user_input: Dict[str, Any] = None
) -> Dict[str, Any]:
"""Handle confirmation flow for discovered bond hub."""
errors = {}
if user_input is not None:
data = user_input.copy()
data[CONF_HOST] = self._discovered[CONF_HOST]
... | [
"async",
"def",
"async_step_confirm",
"(",
"self",
",",
"user_input",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",... | [
80,
4
] | [
98,
9
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_user | (
self, user_input: Dict[str, Any] = None
) | Handle a flow initialized by the user. | Handle a flow initialized by the user. | async def async_step_user(
self, user_input: Dict[str, Any] = None
) -> Dict[str, Any]:
"""Handle a flow initialized by the user."""
errors = {}
if user_input is not None:
try:
return await self._try_create_entry(user_input)
except InputValidat... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
... | [
100,
4
] | [
113,
9
] | python | en | ['en', 'en', 'en'] | True |
InputValidationError.__init__ | (self, base: str) | Initialize with error base. | Initialize with error base. | def __init__(self, base: str):
"""Initialize with error base."""
super().__init__()
self.base = base | [
"def",
"__init__",
"(",
"self",
",",
"base",
":",
"str",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"base",
"=",
"base"
] | [
125,
4
] | [
128,
24
] | python | en | ['en', 'en', 'en'] | True |
test_auth_fail | (
gogogate2api_mock, async_setup_entry_mock, async_setup_mock, hass: HomeAssistant
) | Test authorization failures. | Test authorization failures. | async def test_auth_fail(
gogogate2api_mock, async_setup_entry_mock, async_setup_mock, hass: HomeAssistant
) -> None:
"""Test authorization failures."""
api: GogoGate2Api = MagicMock(spec=GogoGate2Api)
gogogate2api_mock.return_value = api
api.reset_mock()
api.info.side_effect = ApiError(GogoGat... | [
"async",
"def",
"test_auth_fail",
"(",
"gogogate2api_mock",
",",
"async_setup_entry_mock",
",",
"async_setup_mock",
",",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"api",
":",
"GogoGate2Api",
"=",
"MagicMock",
"(",
"spec",
"=",
"GogoGate2Api",
")",
"g... | [
30,
0
] | [
73,
57
] | python | el-Latn | ['fr', 'el-Latn', 'en'] | False |
test_form_homekit_unique_id_already_setup | (hass) | Test that we abort from homekit if gogogate2 is already setup. | Test that we abort from homekit if gogogate2 is already setup. | async def test_form_homekit_unique_id_already_setup(hass):
"""Test that we abort from homekit if gogogate2 is already setup."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entrie... | [
"async",
"def",
"test_form_homekit_unique_id_already_setup",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"fl... | [
76,
0
] | [
105,
46
] | python | en | ['en', 'en', 'en'] | True |
test_form_homekit_ip_address_already_setup | (hass) | Test that we abort from homekit if gogogate2 is already setup. | Test that we abort from homekit if gogogate2 is already setup. | async def test_form_homekit_ip_address_already_setup(hass):
"""Test that we abort from homekit if gogogate2 is already setup."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_IP_ADDRESS: "1.2.3.4", CONF_USERNAME: "m... | [
"async",
"def",
"test_form_homekit_ip_address_already_setup",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
... | [
108,
0
] | [
123,
46
] | python | en | ['en', 'en', 'en'] | True |
test_form_homekit_ip_address | (hass) | Test homekit includes the defaults ip address. | Test homekit includes the defaults ip address. | async def test_form_homekit_ip_address(hass):
"""Test homekit includes the defaults ip address."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_HOMEKIT},
da... | [
"async",
"def",
"test_form_homekit_ip_address",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
... | [
126,
0
] | [
144,
5
] | python | en | ['en', 'en', 'en'] | True |
test_sensor_upper | (hass) | Test if source is above threshold. | Test if source is above threshold. | async def test_sensor_upper(hass):
"""Test if source is above threshold."""
config = {
"binary_sensor": {
"platform": "threshold",
"upper": "15",
"entity_id": "sensor.test_monitored",
}
}
assert await async_setup_component(hass, "binary_sensor", confi... | [
"async",
"def",
"test_sensor_upper",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"binary_sensor\"",
":",
"{",
"\"platform\"",
":",
"\"threshold\"",
",",
"\"upper\"",
":",
"\"15\"",
",",
"\"entity_id\"",
":",
"\"sensor.test_monitored\"",
",",
"}",
"}",
"assert",... | [
6,
0
] | [
47,
31
] | python | en | ['en', 'en', 'en'] | True |
test_sensor_lower | (hass) | Test if source is below threshold. | Test if source is below threshold. | async def test_sensor_lower(hass):
"""Test if source is below threshold."""
config = {
"binary_sensor": {
"platform": "threshold",
"lower": "15",
"entity_id": "sensor.test_monitored",
}
}
assert await async_setup_component(hass, "binary_sensor", confi... | [
"async",
"def",
"test_sensor_lower",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"binary_sensor\"",
":",
"{",
"\"platform\"",
":",
"\"threshold\"",
",",
"\"lower\"",
":",
"\"15\"",
",",
"\"entity_id\"",
":",
"\"sensor.test_monitored\"",
",",
"}",
"}",
"assert",... | [
50,
0
] | [
80,
30
] | python | en | ['en', 'en', 'en'] | True |
test_sensor_hysteresis | (hass) | Test if source is above threshold using hysteresis. | Test if source is above threshold using hysteresis. | async def test_sensor_hysteresis(hass):
"""Test if source is above threshold using hysteresis."""
config = {
"binary_sensor": {
"platform": "threshold",
"upper": "15",
"hysteresis": "2.5",
"entity_id": "sensor.test_monitored",
}
}
assert a... | [
"async",
"def",
"test_sensor_hysteresis",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"binary_sensor\"",
":",
"{",
"\"platform\"",
":",
"\"threshold\"",
",",
"\"upper\"",
":",
"\"15\"",
",",
"\"hysteresis\"",
":",
"\"2.5\"",
",",
"\"entity_id\"",
":",
"\"sensor... | [
83,
0
] | [
135,
30
] | python | en | ['en', 'en', 'en'] | True |
test_sensor_in_range_no_hysteresis | (hass) | Test if source is within the range. | Test if source is within the range. | async def test_sensor_in_range_no_hysteresis(hass):
"""Test if source is within the range."""
config = {
"binary_sensor": {
"platform": "threshold",
"lower": "10",
"upper": "20",
"entity_id": "sensor.test_monitored",
}
}
assert await async... | [
"async",
"def",
"test_sensor_in_range_no_hysteresis",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"binary_sensor\"",
":",
"{",
"\"platform\"",
":",
"\"threshold\"",
",",
"\"lower\"",
":",
"\"10\"",
",",
"\"upper\"",
":",
"\"20\"",
",",
"\"entity_id\"",
":",
"\"... | [
138,
0
] | [
183,
31
] | python | en | ['en', 'en', 'en'] | True |
test_sensor_in_range_with_hysteresis | (hass) | Test if source is within the range. | Test if source is within the range. | async def test_sensor_in_range_with_hysteresis(hass):
"""Test if source is within the range."""
config = {
"binary_sensor": {
"platform": "threshold",
"lower": "10",
"upper": "20",
"hysteresis": "2",
"entity_id": "sensor.test_monitored",
... | [
"async",
"def",
"test_sensor_in_range_with_hysteresis",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"binary_sensor\"",
":",
"{",
"\"platform\"",
":",
"\"threshold\"",
",",
"\"lower\"",
":",
"\"10\"",
",",
"\"upper\"",
":",
"\"20\"",
",",
"\"hysteresis\"",
":",
... | [
186,
0
] | [
282,
30
] | python | en | ['en', 'en', 'en'] | True |
test_sensor_in_range_unknown_state | (hass) | Test if source is within the range. | Test if source is within the range. | async def test_sensor_in_range_unknown_state(hass):
"""Test if source is within the range."""
config = {
"binary_sensor": {
"platform": "threshold",
"lower": "10",
"upper": "20",
"entity_id": "sensor.test_monitored",
}
}
assert await async... | [
"async",
"def",
"test_sensor_in_range_unknown_state",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"binary_sensor\"",
":",
"{",
"\"platform\"",
":",
"\"threshold\"",
",",
"\"lower\"",
":",
"\"10\"",
",",
"\"upper\"",
":",
"\"20\"",
",",
"\"entity_id\"",
":",
"\"... | [
285,
0
] | [
322,
31
] | python | en | ['en', 'en', 'en'] | True |
test_sensor_lower_zero_threshold | (hass) | Test if a lower threshold of zero is set. | Test if a lower threshold of zero is set. | async def test_sensor_lower_zero_threshold(hass):
"""Test if a lower threshold of zero is set."""
config = {
"binary_sensor": {
"platform": "threshold",
"lower": "0",
"entity_id": "sensor.test_monitored",
}
}
assert await async_setup_component(hass, "... | [
"async",
"def",
"test_sensor_lower_zero_threshold",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"binary_sensor\"",
":",
"{",
"\"platform\"",
":",
"\"threshold\"",
",",
"\"lower\"",
":",
"\"0\"",
",",
"\"entity_id\"",
":",
"\"sensor.test_monitored\"",
",",
"}",
"}... | [
325,
0
] | [
353,
30
] | python | en | ['en', 'en', 'en'] | True |
test_sensor_upper_zero_threshold | (hass) | Test if an upper threshold of zero is set. | Test if an upper threshold of zero is set. | async def test_sensor_upper_zero_threshold(hass):
"""Test if an upper threshold of zero is set."""
config = {
"binary_sensor": {
"platform": "threshold",
"upper": "0",
"entity_id": "sensor.test_monitored",
}
}
assert await async_setup_component(hass, ... | [
"async",
"def",
"test_sensor_upper_zero_threshold",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"binary_sensor\"",
":",
"{",
"\"platform\"",
":",
"\"threshold\"",
",",
"\"upper\"",
":",
"\"0\"",
",",
"\"entity_id\"",
":",
"\"sensor.test_monitored\"",
",",
"}",
"}... | [
356,
0
] | [
384,
30
] | python | en | ['en', 'en', 'en'] | True |
async_get_engine | (hass, config, discovery_info=None) | Set up Google speech component. | Set up Google speech component. | async def async_get_engine(hass, config, discovery_info=None):
"""Set up Google speech component."""
return GoogleProvider(hass, config[CONF_LANG]) | [
"async",
"def",
"async_get_engine",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"return",
"GoogleProvider",
"(",
"hass",
",",
"config",
"[",
"CONF_LANG",
"]",
")"
] | [
84,
0
] | [
86,
50
] | python | en | ['en', 'lb', 'en'] | True |
GoogleProvider.__init__ | (self, hass, lang) | Init Google TTS service. | Init Google TTS service. | def __init__(self, hass, lang):
"""Init Google TTS service."""
self.hass = hass
self._lang = lang
self.headers = {
REFERER: "http://translate.google.com/",
USER_AGENT: (
"Mozilla/5.0 (Windows NT 10.0; WOW64) "
"AppleWebKit/537.36 (K... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"lang",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"_lang",
"=",
"lang",
"self",
".",
"headers",
"=",
"{",
"REFERER",
":",
"\"http://translate.google.com/\"",
",",
"USER_AGENT",
":",
"(",
... | [
92,
4
] | [
104,
28
] | python | en | ['en', 'mt', 'en'] | True |
GoogleProvider.default_language | (self) | Return the default language. | Return the default language. | def default_language(self):
"""Return the default language."""
return self._lang | [
"def",
"default_language",
"(",
"self",
")",
":",
"return",
"self",
".",
"_lang"
] | [
107,
4
] | [
109,
25
] | python | en | ['en', 'et', 'en'] | True |
GoogleProvider.supported_languages | (self) | Return list of supported languages. | Return list of supported languages. | def supported_languages(self):
"""Return list of supported languages."""
return SUPPORT_LANGUAGES | [
"def",
"supported_languages",
"(",
"self",
")",
":",
"return",
"SUPPORT_LANGUAGES"
] | [
112,
4
] | [
114,
32
] | python | en | ['en', 'en', 'en'] | True |
GoogleProvider.async_get_tts_audio | (self, message, language, options=None) | Load TTS from google. | Load TTS from google. | async def async_get_tts_audio(self, message, language, options=None):
"""Load TTS from google."""
token = gtts_token.Token()
websession = async_get_clientsession(self.hass)
message_parts = self._split_message_to_parts(message)
data = b""
for idx, part in enumerate(messa... | [
"async",
"def",
"async_get_tts_audio",
"(",
"self",
",",
"message",
",",
"language",
",",
"options",
"=",
"None",
")",
":",
"token",
"=",
"gtts_token",
".",
"Token",
"(",
")",
"websession",
"=",
"async_get_clientsession",
"(",
"self",
".",
"hass",
")",
"me... | [
116,
4
] | [
162,
26
] | python | en | ['en', 'en', 'en'] | True |
GoogleProvider._split_message_to_parts | (message) | Split message into single parts. | Split message into single parts. | def _split_message_to_parts(message):
"""Split message into single parts."""
if len(message) <= MESSAGE_SIZE:
return [message]
punc = "!()[]?.,;:"
punc_list = [re.escape(c) for c in punc]
pattern = "|".join(punc_list)
parts = re.split(pattern, message)
... | [
"def",
"_split_message_to_parts",
"(",
"message",
")",
":",
"if",
"len",
"(",
"message",
")",
"<=",
"MESSAGE_SIZE",
":",
"return",
"[",
"message",
"]",
"punc",
"=",
"\"!()[]?.,;:\"",
"punc_list",
"=",
"[",
"re",
".",
"escape",
"(",
"c",
")",
"for",
"c",
... | [
165,
4
] | [
186,
57
] | python | en | ['it', 'fr', 'en'] | False |
ResourceTrackingAgent.run | (self) | Start tracking node status and updating details.
Returns:
None.
| Start tracking node status and updating details. | def run(self) -> None:
"""Start tracking node status and updating details.
Returns:
None.
"""
while True:
start_time = time.time()
self.push_local_resource_usage()
time.sleep(max(self._check_interval - (time.time() - start_time), 0))
... | [
"def",
"run",
"(",
"self",
")",
"->",
"None",
":",
"while",
"True",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"push_local_resource_usage",
"(",
")",
"time",
".",
"sleep",
"(",
"max",
"(",
"self",
".",
"_check_interval",
"-",
... | [
58,
4
] | [
69,
112
] | python | en | ['en', 'en', 'en'] | True |
get_attention_data | (experiment_name: str, episode: str, tick: str) | Get the attention data within one tick.
Args:
experiment_name (str): Name of the experiment expected to be displayed.
episode (str) : Number of the episode of expected data.
tick (str): Number of tick of expected data.
Returns:
Dataframe: Formatted attention value of curren... | Get the attention data within one tick. | def get_attention_data(experiment_name: str, episode: str, tick: str) -> pd.DataFrame:
"""Get the attention data within one tick.
Args:
experiment_name (str): Name of the experiment expected to be displayed.
episode (str) : Number of the episode of expected data.
tick (str): Number of t... | [
"def",
"get_attention_data",
"(",
"experiment_name",
":",
"str",
",",
"episode",
":",
"str",
",",
"tick",
":",
"str",
")",
"->",
"pd",
".",
"DataFrame",
":",
"get_attention_value_params",
"=",
"{",
"\"query\"",
":",
"f\"select * from {experiment_name}.attentions whe... | [
10,
0
] | [
32,
26
] | python | en | ['en', 'en', 'en'] | True |
load_plum | (username: str, password: str, hass: HomeAssistant) | Initialize Plum Lightpad API and load metadata stored in the cloud. | Initialize Plum Lightpad API and load metadata stored in the cloud. | async def load_plum(username: str, password: str, hass: HomeAssistant) -> Plum:
"""Initialize Plum Lightpad API and load metadata stored in the cloud."""
plum = Plum(username, password)
cloud_web_session = async_get_clientsession(hass, verify_ssl=True)
await plum.loadCloudData(cloud_web_session)
ret... | [
"async",
"def",
"load_plum",
"(",
"username",
":",
"str",
",",
"password",
":",
"str",
",",
"hass",
":",
"HomeAssistant",
")",
"->",
"Plum",
":",
"plum",
"=",
"Plum",
"(",
"username",
",",
"password",
")",
"cloud_web_session",
"=",
"async_get_clientsession",... | [
8,
0
] | [
13,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Perform the setup for Envisalink alarm panels. | Perform the setup for Envisalink alarm panels. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Perform the setup for Envisalink alarm panels."""
configured_partitions = discovery_info["partitions"]
code = discovery_info[CONF_CODE]
panic_type = discovery_info[CONF_PANIC]
devices = []
for part_num in ... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"configured_partitions",
"=",
"discovery_info",
"[",
"\"partitions\"",
"]",
"code",
"=",
"discovery_info",
"[",
"CONF_CODE",
... | [
53,
0
] | [
95,
15
] | python | en | ['en', 'da', 'en'] | True |
EnvisalinkAlarm.__init__ | (
self, hass, partition_number, alarm_name, code, panic_type, info, controller
) | Initialize the alarm panel. | Initialize the alarm panel. | def __init__(
self, hass, partition_number, alarm_name, code, panic_type, info, controller
):
"""Initialize the alarm panel."""
self._partition_number = partition_number
self._code = code
self._panic_type = panic_type
_LOGGER.debug("Setting up alarm: %s", alarm_name)... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"partition_number",
",",
"alarm_name",
",",
"code",
",",
"panic_type",
",",
"info",
",",
"controller",
")",
":",
"self",
".",
"_partition_number",
"=",
"partition_number",
"self",
".",
"_code",
"=",
"code",
... | [
101,
4
] | [
110,
54
] | python | en | ['en', 'en', 'en'] | True |
EnvisalinkAlarm.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
self.async_on_remove(
async_dispatcher_connect(
self.hass, SIGNAL_KEYPAD_UPDATE, self._update_callback
)
)
self.async_on_remove(
async_dispatcher_connect(
se... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_KEYPAD_UPDATE",
",",
"self",
".",
"_update_callback",
")",
")",
"self",
".",
"async_on_remove",
... | [
112,
4
] | [
123,
9
] | python | en | ['en', 'no', 'en'] | False |
EnvisalinkAlarm._update_callback | (self, partition) | Update Home Assistant state, if needed. | Update Home Assistant state, if needed. | def _update_callback(self, partition):
"""Update Home Assistant state, if needed."""
if partition is None or int(partition) == self._partition_number:
self.async_write_ha_state() | [
"def",
"_update_callback",
"(",
"self",
",",
"partition",
")",
":",
"if",
"partition",
"is",
"None",
"or",
"int",
"(",
"partition",
")",
"==",
"self",
".",
"_partition_number",
":",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
126,
4
] | [
129,
39
] | python | en | ['en', 'en', 'en'] | True |
EnvisalinkAlarm.code_format | (self) | Regex for code format or None if no code is required. | Regex for code format or None if no code is required. | def code_format(self):
"""Regex for code format or None if no code is required."""
if self._code:
return None
return FORMAT_NUMBER | [
"def",
"code_format",
"(",
"self",
")",
":",
"if",
"self",
".",
"_code",
":",
"return",
"None",
"return",
"FORMAT_NUMBER"
] | [
132,
4
] | [
136,
28
] | python | en | ['en', 'en', 'en'] | True |
EnvisalinkAlarm.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
state = STATE_UNKNOWN
if self._info["status"]["alarm"]:
state = STATE_ALARM_TRIGGERED
elif self._info["status"]["armed_zero_entry_delay"]:
state = STATE_ALARM_ARMED_NIGHT
elif self._info["status"]["ar... | [
"def",
"state",
"(",
"self",
")",
":",
"state",
"=",
"STATE_UNKNOWN",
"if",
"self",
".",
"_info",
"[",
"\"status\"",
"]",
"[",
"\"alarm\"",
"]",
":",
"state",
"=",
"STATE_ALARM_TRIGGERED",
"elif",
"self",
".",
"_info",
"[",
"\"status\"",
"]",
"[",
"\"arm... | [
139,
4
] | [
157,
20
] | python | en | ['en', 'en', 'en'] | True |
EnvisalinkAlarm.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self) -> int:
"""Return the list of supported features."""
return (
SUPPORT_ALARM_ARM_HOME
| SUPPORT_ALARM_ARM_AWAY
| SUPPORT_ALARM_ARM_NIGHT
| SUPPORT_ALARM_TRIGGER
) | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"(",
"SUPPORT_ALARM_ARM_HOME",
"|",
"SUPPORT_ALARM_ARM_AWAY",
"|",
"SUPPORT_ALARM_ARM_NIGHT",
"|",
"SUPPORT_ALARM_TRIGGER",
")"
] | [
160,
4
] | [
167,
9
] | 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.