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
MonopriceOptionsFlowHandler.__init__
(self, config_entry)
Initialize.
Initialize.
def __init__(self, config_entry): """Initialize.""" self.config_entry = config_entry
[ "def", "__init__", "(", "self", ",", "config_entry", ")", ":", "self", ".", "config_entry", "=", "config_entry" ]
[ 113, 4 ]
[ 115, 40 ]
python
en
['en', 'en', 'it']
False
MonopriceOptionsFlowHandler.async_step_init
(self, user_input=None)
Manage the options.
Manage the options.
async def async_step_init(self, user_input=None): """Manage the options.""" if user_input is not None: return self.async_create_entry( title="", data={CONF_SOURCES: _sources_from_config(user_input)} ) previous_sources = self._previous_sources() o...
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "return", "self", ".", "async_create_entry", "(", "title", "=", "\"\"", ",", "data", "=", "{", "CONF_SOURCES", ":", "_...
[ 126, 4 ]
[ 143, 9 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Find and return LightWave lights.
Find and return LightWave lights.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Find and return LightWave lights.""" if discovery_info is None: return entities = [] lwlink = hass.data[LIGHTWAVE_LINK] for device_id, device_config in discovery_info.items(): name = device_co...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "entities", "=", "[", "]", "lwlink", "=", "hass", ".", "data", ...
[ 15, 0 ]
[ 28, 32 ]
python
en
['en', 'da', 'en']
True
LightwaveTrv.__init__
(self, name, device_id, lwlink, serial)
Initialize LightwaveTrv entity.
Initialize LightwaveTrv entity.
def __init__(self, name, device_id, lwlink, serial): """Initialize LightwaveTrv entity.""" self._name = name self._device_id = device_id self._state = None self._current_temperature = None self._target_temperature = None self._hvac_action = None self._lwli...
[ "def", "__init__", "(", "self", ",", "name", ",", "device_id", ",", "lwlink", ",", "serial", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_device_id", "=", "device_id", "self", ".", "_state", "=", "None", "self", ".", "_current_temperature"...
[ 34, 4 ]
[ 45, 25 ]
python
da
['en', 'da', 'it']
False
LightwaveTrv.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return SUPPORT_TARGET_TEMPERATURE
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_TARGET_TEMPERATURE" ]
[ 48, 4 ]
[ 50, 41 ]
python
en
['da', 'en', 'en']
True
LightwaveTrv.update
(self)
Communicate with a Lightwave RTF Proxy to get state.
Communicate with a Lightwave RTF Proxy to get state.
def update(self): """Communicate with a Lightwave RTF Proxy to get state.""" (temp, targ, _, trv_output) = self._lwlink.read_trv_status(self._serial) if temp is not None: self._current_temperature = temp if targ is not None: if self._inhibit == 0: ...
[ "def", "update", "(", "self", ")", ":", "(", "temp", ",", "targ", ",", "_", ",", "trv_output", ")", "=", "self", ".", "_lwlink", ".", "read_trv_status", "(", "self", ".", "_serial", ")", "if", "temp", "is", "not", "None", ":", "self", ".", "_curren...
[ 52, 4 ]
[ 73, 52 ]
python
en
['en', 'en', 'en']
True
LightwaveTrv.name
(self)
Lightwave trv name.
Lightwave trv name.
def name(self): """Lightwave trv name.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 76, 4 ]
[ 78, 25 ]
python
en
['en', 'da', 'en']
True
LightwaveTrv.current_temperature
(self)
Property giving the current room temperature.
Property giving the current room temperature.
def current_temperature(self): """Property giving the current room temperature.""" return self._current_temperature
[ "def", "current_temperature", "(", "self", ")", ":", "return", "self", ".", "_current_temperature" ]
[ 81, 4 ]
[ 83, 40 ]
python
en
['en', 'en', 'en']
True
LightwaveTrv.target_temperature
(self)
Target room temperature.
Target room temperature.
def target_temperature(self): """Target room temperature.""" if self._inhibit > 0: # If we get an update before the new temp has # propagated, the target temp is set back to the # old target on the next poll, showing a false # reading temporarily. ...
[ "def", "target_temperature", "(", "self", ")", ":", "if", "self", ".", "_inhibit", ">", "0", ":", "# If we get an update before the new temp has", "# propagated, the target temp is set back to the", "# old target on the next poll, showing a false", "# reading temporarily.", "self",...
[ 86, 4 ]
[ 94, 39 ]
python
en
['en', 'la', 'en']
True
LightwaveTrv.hvac_modes
(self)
HVAC modes.
HVAC modes.
def hvac_modes(self): """HVAC modes.""" return [HVAC_MODE_HEAT, HVAC_MODE_OFF]
[ "def", "hvac_modes", "(", "self", ")", ":", "return", "[", "HVAC_MODE_HEAT", ",", "HVAC_MODE_OFF", "]" ]
[ 97, 4 ]
[ 99, 46 ]
python
en
['en', 'hi-Latn', 'en']
False
LightwaveTrv.hvac_action
(self)
HVAC action.
HVAC action.
def hvac_action(self): """HVAC action.""" return self._hvac_action
[ "def", "hvac_action", "(", "self", ")", ":", "return", "self", ".", "_hvac_action" ]
[ 107, 4 ]
[ 109, 32 ]
python
en
['en', 'ja', 'en']
False
LightwaveTrv.temperature_unit
(self)
Set temperature unit.
Set temperature unit.
def temperature_unit(self): """Set temperature unit.""" return TEMP_CELSIUS
[ "def", "temperature_unit", "(", "self", ")", ":", "return", "TEMP_CELSIUS" ]
[ 122, 4 ]
[ 124, 27 ]
python
en
['es', 'la', 'en']
False
LightwaveTrv.target_temperature_step
(self)
Set temperature step.
Set temperature step.
def target_temperature_step(self): """Set temperature step.""" return 0.5
[ "def", "target_temperature_step", "(", "self", ")", ":", "return", "0.5" ]
[ 127, 4 ]
[ 129, 18 ]
python
en
['en', 'la', 'en']
True
LightwaveTrv.set_temperature
(self, **kwargs)
Set TRV target temperature.
Set TRV target temperature.
def set_temperature(self, **kwargs): """Set TRV target temperature.""" if ATTR_TEMPERATURE in kwargs: self._target_temperature = kwargs[ATTR_TEMPERATURE] self._inhibit = self._target_temperature self._lwlink.set_temperature( self._device_id, self._target_tempe...
[ "def", "set_temperature", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "ATTR_TEMPERATURE", "in", "kwargs", ":", "self", ".", "_target_temperature", "=", "kwargs", "[", "ATTR_TEMPERATURE", "]", "self", ".", "_inhibit", "=", "self", ".", "_target_temp...
[ 131, 4 ]
[ 138, 9 ]
python
en
['en', 'la', 'en']
True
LightwaveTrv.async_set_hvac_mode
(self, hvac_mode)
Set HVAC Mode for TRV.
Set HVAC Mode for TRV.
async def async_set_hvac_mode(self, hvac_mode): """Set HVAC Mode for TRV."""
[ "async", "def", "async_set_hvac_mode", "(", "self", ",", "hvac_mode", ")", ":" ]
[ 140, 4 ]
[ 141, 36 ]
python
da
['da', 'pt', 'en']
False
async_get_registry
(hass: HomeAssistantType)
Return zha device storage instance.
Return zha device storage instance.
async def async_get_registry(hass: HomeAssistantType) -> ZhaStorage: """Return zha device storage instance.""" task = hass.data.get(DATA_REGISTRY) if task is None: async def _load_reg() -> ZhaStorage: registry = ZhaStorage(hass) await registry.async_load() retur...
[ "async", "def", "async_get_registry", "(", "hass", ":", "HomeAssistantType", ")", "->", "ZhaStorage", ":", "task", "=", "hass", ".", "data", ".", "get", "(", "DATA_REGISTRY", ")", "if", "task", "is", "None", ":", "async", "def", "_load_reg", "(", ")", "-...
[ 130, 0 ]
[ 143, 39 ]
python
br
['br', 'pl', 'en']
False
ZhaStorage.__init__
(self, hass: HomeAssistantType)
Initialize the zha device storage.
Initialize the zha device storage.
def __init__(self, hass: HomeAssistantType) -> None: """Initialize the zha device storage.""" self.hass: HomeAssistantType = hass self.devices: MutableMapping[str, ZhaDeviceEntry] = {} self._store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY)
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistantType", ")", "->", "None", ":", "self", ".", "hass", ":", "HomeAssistantType", "=", "hass", "self", ".", "devices", ":", "MutableMapping", "[", "str", ",", "ZhaDeviceEntry", "]", "=", "{", "}...
[ 35, 4 ]
[ 39, 78 ]
python
br
['br', 'pl', 'en']
False
ZhaStorage.async_create_device
(self, device: ZhaDeviceType)
Create a new ZhaDeviceEntry.
Create a new ZhaDeviceEntry.
def async_create_device(self, device: ZhaDeviceType) -> ZhaDeviceEntry: """Create a new ZhaDeviceEntry.""" device_entry: ZhaDeviceEntry = ZhaDeviceEntry( name=device.name, ieee=str(device.ieee), last_seen=device.last_seen ) self.devices[device_entry.ieee] = device_entry ...
[ "def", "async_create_device", "(", "self", ",", "device", ":", "ZhaDeviceType", ")", "->", "ZhaDeviceEntry", ":", "device_entry", ":", "ZhaDeviceEntry", "=", "ZhaDeviceEntry", "(", "name", "=", "device", ".", "name", ",", "ieee", "=", "str", "(", "device", "...
[ 42, 4 ]
[ 49, 27 ]
python
en
['en', 'en', 'en']
True
ZhaStorage.async_get_or_create_device
(self, device: ZhaDeviceType)
Create a new ZhaDeviceEntry.
Create a new ZhaDeviceEntry.
def async_get_or_create_device(self, device: ZhaDeviceType) -> ZhaDeviceEntry: """Create a new ZhaDeviceEntry.""" ieee_str: str = str(device.ieee) if ieee_str in self.devices: return self.devices[ieee_str] return self.async_create_device(device)
[ "def", "async_get_or_create_device", "(", "self", ",", "device", ":", "ZhaDeviceType", ")", "->", "ZhaDeviceEntry", ":", "ieee_str", ":", "str", "=", "str", "(", "device", ".", "ieee", ")", "if", "ieee_str", "in", "self", ".", "devices", ":", "return", "se...
[ 52, 4 ]
[ 57, 47 ]
python
en
['en', 'en', 'en']
True
ZhaStorage.async_create_or_update_device
(self, device: ZhaDeviceType)
Create or update a ZhaDeviceEntry.
Create or update a ZhaDeviceEntry.
def async_create_or_update_device(self, device: ZhaDeviceType) -> ZhaDeviceEntry: """Create or update a ZhaDeviceEntry.""" if str(device.ieee) in self.devices: return self.async_update_device(device) return self.async_create_device(device)
[ "def", "async_create_or_update_device", "(", "self", ",", "device", ":", "ZhaDeviceType", ")", "->", "ZhaDeviceEntry", ":", "if", "str", "(", "device", ".", "ieee", ")", "in", "self", ".", "devices", ":", "return", "self", ".", "async_update_device", "(", "d...
[ 60, 4 ]
[ 64, 47 ]
python
en
['en', 'en', 'en']
True
ZhaStorage.async_delete_device
(self, device: ZhaDeviceType)
Delete ZhaDeviceEntry.
Delete ZhaDeviceEntry.
def async_delete_device(self, device: ZhaDeviceType) -> None: """Delete ZhaDeviceEntry.""" ieee_str: str = str(device.ieee) if ieee_str in self.devices: del self.devices[ieee_str] self.async_schedule_save()
[ "def", "async_delete_device", "(", "self", ",", "device", ":", "ZhaDeviceType", ")", "->", "None", ":", "ieee_str", ":", "str", "=", "str", "(", "device", ".", "ieee", ")", "if", "ieee_str", "in", "self", ".", "devices", ":", "del", "self", ".", "devic...
[ 67, 4 ]
[ 72, 38 ]
python
en
['en', 'sr', 'pt']
False
ZhaStorage.async_update_device
(self, device: ZhaDeviceType)
Update name of ZhaDeviceEntry.
Update name of ZhaDeviceEntry.
def async_update_device(self, device: ZhaDeviceType) -> ZhaDeviceEntry: """Update name of ZhaDeviceEntry.""" ieee_str: str = str(device.ieee) old = self.devices[ieee_str] if old is not None and device.last_seen is None: return changes = {} changes["last_seen...
[ "def", "async_update_device", "(", "self", ",", "device", ":", "ZhaDeviceType", ")", "->", "ZhaDeviceEntry", ":", "ieee_str", ":", "str", "=", "str", "(", "device", ".", "ieee", ")", "old", "=", "self", ".", "devices", "[", "ieee_str", "]", "if", "old", ...
[ 75, 4 ]
[ 88, 18 ]
python
en
['en', 'en', 'en']
True
ZhaStorage.async_load
(self)
Load the registry of zha device entries.
Load the registry of zha device entries.
async def async_load(self) -> None: """Load the registry of zha device entries.""" data = await self._store.async_load() devices: "OrderedDict[str, ZhaDeviceEntry]" = OrderedDict() if data is not None: for device in data["devices"]: devices[device["ieee"]] =...
[ "async", "def", "async_load", "(", "self", ")", "->", "None", ":", "data", "=", "await", "self", ".", "_store", ".", "async_load", "(", ")", "devices", ":", "\"OrderedDict[str, ZhaDeviceEntry]\"", "=", "OrderedDict", "(", ")", "if", "data", "is", "not", "N...
[ 90, 4 ]
[ 104, 30 ]
python
en
['en', 'en', 'en']
True
ZhaStorage.async_schedule_save
(self)
Schedule saving the registry of zha devices.
Schedule saving the registry of zha devices.
def async_schedule_save(self) -> None: """Schedule saving the registry of zha devices.""" self._store.async_delay_save(self._data_to_save, SAVE_DELAY)
[ "def", "async_schedule_save", "(", "self", ")", "->", "None", ":", "self", ".", "_store", ".", "async_delay_save", "(", "self", ".", "_data_to_save", ",", "SAVE_DELAY", ")" ]
[ 107, 4 ]
[ 109, 68 ]
python
en
['en', 'en', 'en']
True
ZhaStorage.async_save
(self)
Save the registry of zha devices.
Save the registry of zha devices.
async def async_save(self) -> None: """Save the registry of zha devices.""" await self._store.async_save(self._data_to_save())
[ "async", "def", "async_save", "(", "self", ")", "->", "None", ":", "await", "self", ".", "_store", ".", "async_save", "(", "self", ".", "_data_to_save", "(", ")", ")" ]
[ 111, 4 ]
[ 113, 58 ]
python
en
['en', 'en', 'en']
True
ZhaStorage._data_to_save
(self)
Return data for the registry of zha devices to store in a file.
Return data for the registry of zha devices to store in a file.
def _data_to_save(self) -> dict: """Return data for the registry of zha devices to store in a file.""" data = {} data["devices"] = [ {"name": entry.name, "ieee": entry.ieee, "last_seen": entry.last_seen} for entry in self.devices.values() if entry.last_seen a...
[ "def", "_data_to_save", "(", "self", ")", "->", "dict", ":", "data", "=", "{", "}", "data", "[", "\"devices\"", "]", "=", "[", "{", "\"name\"", ":", "entry", ".", "name", ",", "\"ieee\"", ":", "entry", ".", "ieee", ",", "\"last_seen\"", ":", "entry",...
[ 116, 4 ]
[ 126, 19 ]
python
en
['en', 'en', 'en']
True
_async_reproduce_state
( hass: HomeAssistantType, state: State, *, context: Optional[Context] = None, reproduce_options: Optional[Dict[str, Any]] = None, )
Reproduce a single state.
Reproduce a single state.
async def _async_reproduce_state( hass: HomeAssistantType, state: State, *, context: Optional[Context] = None, reproduce_options: Optional[Dict[str, Any]] = None, ) -> None: """Reproduce a single state.""" cur_state = hass.states.get(state.entity_id) if cur_state is None: _LOGGE...
[ "async", "def", "_async_reproduce_state", "(", "hass", ":", "HomeAssistantType", ",", "state", ":", "State", ",", "*", ",", "context", ":", "Optional", "[", "Context", "]", "=", "None", ",", "reproduce_options", ":", "Optional", "[", "Dict", "[", "str", ",...
[ 22, 0 ]
[ 55, 5 ]
python
en
['en', 'en', 'en']
True
async_reproduce_states
( hass: HomeAssistantType, states: Iterable[State], *, context: Optional[Context] = None, reproduce_options: Optional[Dict[str, Any]] = None, )
Reproduce Switch states.
Reproduce Switch states.
async def async_reproduce_states( hass: HomeAssistantType, states: Iterable[State], *, context: Optional[Context] = None, reproduce_options: Optional[Dict[str, Any]] = None, ) -> None: """Reproduce Switch states.""" await asyncio.gather( *( _async_reproduce_state( ...
[ "async", "def", "async_reproduce_states", "(", "hass", ":", "HomeAssistantType", ",", "states", ":", "Iterable", "[", "State", "]", ",", "*", ",", "context", ":", "Optional", "[", "Context", "]", "=", "None", ",", "reproduce_options", ":", "Optional", "[", ...
[ 58, 0 ]
[ 73, 5 ]
python
en
['en', 'en', 'en']
True
test_air_con
(hass)
Test creation of aircon climate.
Test creation of aircon climate.
async def test_air_con(hass): """Test creation of aircon climate.""" await async_init_integration(hass) state = hass.states.get("climate.air_conditioning") assert state.state == "cool" expected_attributes = { "current_humidity": 60.9, "current_temperature": 24.8, "fan_mode...
[ "async", "def", "test_air_con", "(", "hass", ")", ":", "await", "async_init_integration", "(", "hass", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "\"climate.air_conditioning\"", ")", "assert", "state", ".", "state", "==", "\"cool\"", "expected_...
[ 5, 0 ]
[ 31, 88 ]
python
en
['en', 'en', 'en']
True
test_heater
(hass)
Test creation of heater climate.
Test creation of heater climate.
async def test_heater(hass): """Test creation of heater climate.""" await async_init_integration(hass) state = hass.states.get("climate.baseboard_heater") assert state.state == "heat" expected_attributes = { "current_humidity": 45.2, "current_temperature": 20.6, "friendly_...
[ "async", "def", "test_heater", "(", "hass", ")", ":", "await", "async_init_integration", "(", "hass", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "\"climate.baseboard_heater\"", ")", "assert", "state", ".", "state", "==", "\"heat\"", "expected_a...
[ 34, 0 ]
[ 58, 88 ]
python
en
['en', 'en', 'en']
True
test_smartac_with_swing
(hass)
Test creation of smart ac with swing climate.
Test creation of smart ac with swing climate.
async def test_smartac_with_swing(hass): """Test creation of smart ac with swing climate.""" await async_init_integration(hass) state = hass.states.get("climate.air_conditioning_with_swing") assert state.state == "auto" expected_attributes = { "current_humidity": 42.3, "current_te...
[ "async", "def", "test_smartac_with_swing", "(", "hass", ")", ":", "await", "async_init_integration", "(", "hass", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "\"climate.air_conditioning_with_swing\"", ")", "assert", "state", ".", "state", "==", "\...
[ 61, 0 ]
[ 88, 88 ]
python
en
['en', 'en', 'en']
True
shift_tokens_right
(input_ids: torch.Tensor, pad_token_id: int, decoder_start_token_id: int)
Shift input ids one token to the right.
Shift input ids one token to the right.
def shift_tokens_right(input_ids: torch.Tensor, pad_token_id: int, decoder_start_token_id: int): """ Shift input ids one token to the right. """ shifted_input_ids = input_ids.new_zeros(input_ids.shape) shifted_input_ids[:, 1:] = input_ids[:, :-1].clone() shifted_input_ids[:, 0] = decoder_start_t...
[ "def", "shift_tokens_right", "(", "input_ids", ":", "torch", ".", "Tensor", ",", "pad_token_id", ":", "int", ",", "decoder_start_token_id", ":", "int", ")", ":", "shifted_input_ids", "=", "input_ids", ".", "new_zeros", "(", "input_ids", ".", "shape", ")", "shi...
[ 61, 0 ]
[ 73, 28 ]
python
en
['en', 'error', 'th']
False
_make_causal_mask
(input_ids_shape: torch.Size, dtype: torch.dtype, past_key_values_length: int = 0)
Make causal mask used for bi-directional self-attention.
Make causal mask used for bi-directional self-attention.
def _make_causal_mask(input_ids_shape: torch.Size, dtype: torch.dtype, past_key_values_length: int = 0): """ Make causal mask used for bi-directional self-attention. """ bsz, tgt_len = input_ids_shape mask = torch.full((tgt_len, tgt_len), float("-inf")) mask_cond = torch.arange(mask.size(-1)) ...
[ "def", "_make_causal_mask", "(", "input_ids_shape", ":", "torch", ".", "Size", ",", "dtype", ":", "torch", ".", "dtype", ",", "past_key_values_length", ":", "int", "=", "0", ")", ":", "bsz", ",", "tgt_len", "=", "input_ids_shape", "mask", "=", "torch", "."...
[ 77, 0 ]
[ 89, 91 ]
python
en
['en', 'error', 'th']
False
_expand_mask
(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None)
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
def _expand_mask(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None): """ Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`. """ bsz, src_len = mask.size() tgt_len = tgt_len if tgt_len is not None else src_len expanded_mask = mask[:, None, N...
[ "def", "_expand_mask", "(", "mask", ":", "torch", ".", "Tensor", ",", "dtype", ":", "torch", ".", "dtype", ",", "tgt_len", ":", "Optional", "[", "int", "]", "=", "None", ")", ":", "bsz", ",", "src_len", "=", "mask", ".", "size", "(", ")", "tgt_len"...
[ 93, 0 ]
[ 104, 82 ]
python
en
['en', 'error', 'th']
False
MarianSinusoidalPositionalEmbedding._init_weight
(out: nn.Parameter)
Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in the 2nd half of the vector. [dim // 2:]
Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in the 2nd half of the vector. [dim // 2:]
def _init_weight(out: nn.Parameter): """ Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in the 2nd half of the vector. [dim // 2:] """ n_pos, dim = out.shape position_enc = np.array( [[pos / np.power...
[ "def", "_init_weight", "(", "out", ":", "nn", ".", "Parameter", ")", ":", "n_pos", ",", "dim", "=", "out", ".", "shape", "position_enc", "=", "np", ".", "array", "(", "[", "[", "pos", "/", "np", ".", "power", "(", "10000", ",", "2", "*", "(", "...
[ 115, 4 ]
[ 129, 18 ]
python
en
['en', 'error', 'th']
False
MarianSinusoidalPositionalEmbedding.forward
(self, input_ids_shape: torch.Size, past_key_values_length: int = 0)
`input_ids_shape` is expected to be [bsz x seqlen].
`input_ids_shape` is expected to be [bsz x seqlen].
def forward(self, input_ids_shape: torch.Size, past_key_values_length: int = 0): """`input_ids_shape` is expected to be [bsz x seqlen].""" bsz, seq_len = input_ids_shape[:2] positions = torch.arange( past_key_values_length, past_key_values_length + seq_len, dtype=torch.long, device=s...
[ "def", "forward", "(", "self", ",", "input_ids_shape", ":", "torch", ".", "Size", ",", "past_key_values_length", ":", "int", "=", "0", ")", ":", "bsz", ",", "seq_len", "=", "input_ids_shape", "[", ":", "2", "]", "positions", "=", "torch", ".", "arange", ...
[ 132, 4 ]
[ 138, 41 ]
python
en
['en', 'en', 'en']
True
MarianAttention.forward
( self, hidden_states: torch.Tensor, key_value_states: Optional[torch.Tensor] = None, past_key_value: Optional[Tuple[torch.Tensor]] = None, attention_mask: Optional[torch.Tensor] = None, layer_head_mask: Optional[torch.Tensor] = None, output_attentions: bool = Fal...
Input shape: Batch x Time x Channel
Input shape: Batch x Time x Channel
def forward( self, hidden_states: torch.Tensor, key_value_states: Optional[torch.Tensor] = None, past_key_value: Optional[Tuple[torch.Tensor]] = None, attention_mask: Optional[torch.Tensor] = None, layer_head_mask: Optional[torch.Tensor] = None, output_attentions:...
[ "def", "forward", "(", "self", ",", "hidden_states", ":", "torch", ".", "Tensor", ",", "key_value_states", ":", "Optional", "[", "torch", ".", "Tensor", "]", "=", "None", ",", "past_key_value", ":", "Optional", "[", "Tuple", "[", "torch", ".", "Tensor", ...
[ 172, 4 ]
[ 281, 65 ]
python
en
['en', 'pl', 'en']
True
MarianEncoderLayer.forward
( self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, layer_head_mask: torch.Tensor, output_attentions: bool = False, )
Args: hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed_dim)` attention_mask (:obj:`torch.FloatTensor`): attention mask of size `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values. ...
Args: hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed_dim)` attention_mask (:obj:`torch.FloatTensor`): attention mask of size `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values. ...
def forward( self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, layer_head_mask: torch.Tensor, output_attentions: bool = False, ): """ Args: hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed...
[ "def", "forward", "(", "self", ",", "hidden_states", ":", "torch", ".", "Tensor", ",", "attention_mask", ":", "torch", ".", "Tensor", ",", "layer_head_mask", ":", "torch", ".", "Tensor", ",", "output_attentions", ":", "bool", "=", "False", ",", ")", ":", ...
[ 302, 4 ]
[ 350, 22 ]
python
en
['en', 'error', 'th']
False
MarianDecoderLayer.forward
( self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor] = None, encoder_hidden_states: Optional[torch.Tensor] = None, encoder_attention_mask: Optional[torch.Tensor] = None, layer_head_mask: Optional[torch.Tensor] = None, encoder_layer_head_mask...
Args: hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed_dim)` attention_mask (:obj:`torch.FloatTensor`): attention mask of size `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values. ...
Args: hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed_dim)` attention_mask (:obj:`torch.FloatTensor`): attention mask of size `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values. ...
def forward( self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor] = None, encoder_hidden_states: Optional[torch.Tensor] = None, encoder_attention_mask: Optional[torch.Tensor] = None, layer_head_mask: Optional[torch.Tensor] = None, encoder_laye...
[ "def", "forward", "(", "self", ",", "hidden_states", ":", "torch", ".", "Tensor", ",", "attention_mask", ":", "Optional", "[", "torch", ".", "Tensor", "]", "=", "None", ",", "encoder_hidden_states", ":", "Optional", "[", "torch", ".", "Tensor", "]", "=", ...
[ 381, 4 ]
[ 467, 22 ]
python
en
['en', 'error', 'th']
False
MarianEncoder.forward
( self, input_ids=None, attention_mask=None, head_mask=None, inputs_embeds=None, output_attentions=None, output_hidden_states=None, return_dict=None, )
r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide it. Indices can be obtained using :class:`~transfor...
r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide it.
def forward( self, input_ids=None, attention_mask=None, head_mask=None, inputs_embeds=None, output_attentions=None, output_hidden_states=None, return_dict=None, ): r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:...
[ "def", "forward", "(", "self", ",", "input_ids", "=", "None", ",", "attention_mask", "=", "None", ",", "head_mask", "=", "None", ",", "inputs_embeds", "=", "None", ",", "output_attentions", "=", "None", ",", "output_hidden_states", "=", "None", ",", "return_...
[ 656, 4 ]
[ 783, 9 ]
python
cy
['en', 'cy', 'hi']
False
MarianDecoder.forward
( self, input_ids=None, attention_mask=None, encoder_hidden_states=None, encoder_attention_mask=None, head_mask=None, encoder_head_mask=None, past_key_values=None, inputs_embeds=None, use_cache=None, output_attentions=None, ...
r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide it. Indices can be obtained using :class:`~transfor...
r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide it.
def forward( self, input_ids=None, attention_mask=None, encoder_hidden_states=None, encoder_attention_mask=None, head_mask=None, encoder_head_mask=None, past_key_values=None, inputs_embeds=None, use_cache=None, output_attentions=Non...
[ "def", "forward", "(", "self", ",", "input_ids", "=", "None", ",", "attention_mask", "=", "None", ",", "encoder_hidden_states", "=", "None", ",", "encoder_attention_mask", "=", "None", ",", "head_mask", "=", "None", ",", "encoder_head_mask", "=", "None", ",", ...
[ 841, 4 ]
[ 1047, 9 ]
python
cy
['en', 'cy', 'hi']
False
MarianForCausalLM.forward
( self, input_ids=None, attention_mask=None, encoder_hidden_states=None, encoder_attention_mask=None, head_mask=None, encoder_head_mask=None, past_key_values=None, inputs_embeds=None, labels=None, use_cache=None, output_atte...
r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide it. Indices can be obtained using :class:`~transfor...
r""" Args: input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide it.
def forward( self, input_ids=None, attention_mask=None, encoder_hidden_states=None, encoder_attention_mask=None, head_mask=None, encoder_head_mask=None, past_key_values=None, inputs_embeds=None, labels=None, use_cache=None, ...
[ "def", "forward", "(", "self", ",", "input_ids", "=", "None", ",", "attention_mask", "=", "None", ",", "encoder_hidden_states", "=", "None", ",", "encoder_attention_mask", "=", "None", ",", "head_mask", "=", "None", ",", "encoder_head_mask", "=", "None", ",", ...
[ 1390, 4 ]
[ 1525, 9 ]
python
cy
['en', 'cy', 'hi']
False
XLNetTokenizer._tokenize
(self, text, sample=False)
Tokenize a string.
Tokenize a string.
def _tokenize(self, text, sample=False): """ Tokenize a string. """ text = self.preprocess_text(text) if not sample: pieces = self.sp_model.EncodeAsPieces(text) else: pieces = self.sp_model.SampleEncodeAsPieces(text, 64, 0.1) new_pieces = [] for p...
[ "def", "_tokenize", "(", "self", ",", "text", ",", "sample", "=", "False", ")", ":", "text", "=", "self", ".", "preprocess_text", "(", "text", ")", "if", "not", "sample", ":", "pieces", "=", "self", ".", "sp_model", ".", "EncodeAsPieces", "(", "text", ...
[ 190, 4 ]
[ 212, 25 ]
python
en
['en', 'gl', 'en']
True
XLNetTokenizer._convert_token_to_id
(self, token)
Converts a token (str) in an id using the vocab.
Converts a token (str) in an id using the vocab.
def _convert_token_to_id(self, token): """ Converts a token (str) in an id using the vocab. """ return self.sp_model.PieceToId(token)
[ "def", "_convert_token_to_id", "(", "self", ",", "token", ")", ":", "return", "self", ".", "sp_model", ".", "PieceToId", "(", "token", ")" ]
[ 214, 4 ]
[ 216, 45 ]
python
en
['en', 'en', 'en']
True
XLNetTokenizer._convert_id_to_token
(self, index)
Converts an index (integer) in a token (str) using the vocab.
Converts an index (integer) in a token (str) using the vocab.
def _convert_id_to_token(self, index): """Converts an index (integer) in a token (str) using the vocab.""" return self.sp_model.IdToPiece(index)
[ "def", "_convert_id_to_token", "(", "self", ",", "index", ")", ":", "return", "self", ".", "sp_model", ".", "IdToPiece", "(", "index", ")" ]
[ 218, 4 ]
[ 220, 45 ]
python
en
['en', 'en', 'en']
True
XLNetTokenizer.convert_tokens_to_string
(self, tokens)
Converts a sequence of tokens (strings for sub-words) in a single string.
Converts a sequence of tokens (strings for sub-words) in a single string.
def convert_tokens_to_string(self, tokens): """Converts a sequence of tokens (strings for sub-words) in a single string.""" out_string = "".join(tokens).replace(SPIECE_UNDERLINE, " ").strip() return out_string
[ "def", "convert_tokens_to_string", "(", "self", ",", "tokens", ")", ":", "out_string", "=", "\"\"", ".", "join", "(", "tokens", ")", ".", "replace", "(", "SPIECE_UNDERLINE", ",", "\" \"", ")", ".", "strip", "(", ")", "return", "out_string" ]
[ 222, 4 ]
[ 225, 25 ]
python
en
['en', 'en', 'en']
True
XLNetTokenizer.build_inputs_with_special_tokens
( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None )
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An XLNet sequence has the following format: - single sequence: ``X <sep> <cls>`` - pair of sequences: ``A <sep> B <sep> <cls>`` Args: ...
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An XLNet sequence has the following format:
def build_inputs_with_special_tokens( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None ) -> List[int]: """ Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An XLNet sequence has...
[ "def", "build_inputs_with_special_tokens", "(", "self", ",", "token_ids_0", ":", "List", "[", "int", "]", ",", "token_ids_1", ":", "Optional", "[", "List", "[", "int", "]", "]", "=", "None", ")", "->", "List", "[", "int", "]", ":", "sep", "=", "[", "...
[ 227, 4 ]
[ 250, 58 ]
python
en
['en', 'error', 'th']
False
XLNetTokenizer.get_special_tokens_mask
( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False )
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding special tokens using the tokenizer ``prepare_for_model`` method. Args: token_ids_0 (:obj:`List[int]`): List of IDs. token_ids_1 (:obj:`List[int]`,...
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding special tokens using the tokenizer ``prepare_for_model`` method.
def get_special_tokens_mask( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False ) -> List[int]: """ Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding special tokens ...
[ "def", "get_special_tokens_mask", "(", "self", ",", "token_ids_0", ":", "List", "[", "int", "]", ",", "token_ids_1", ":", "Optional", "[", "List", "[", "int", "]", "]", "=", "None", ",", "already_has_special_tokens", ":", "bool", "=", "False", ")", "->", ...
[ 252, 4 ]
[ 281, 48 ]
python
en
['en', 'error', 'th']
False
XLNetTokenizer.create_token_type_ids_from_sequences
( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None )
Create a mask from the two sequences passed to be used in a sequence-pair classification task. An XLNet sequence pair mask has the following format: :: 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 | first sequence | second sequence | If :obj:`token_ids_1` is :ob...
Create a mask from the two sequences passed to be used in a sequence-pair classification task. An XLNet sequence pair mask has the following format:
def create_token_type_ids_from_sequences( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None ) -> List[int]: """ Create a mask from the two sequences passed to be used in a sequence-pair classification task. An XLNet sequence pair mask has the following format: ...
[ "def", "create_token_type_ids_from_sequences", "(", "self", ",", "token_ids_0", ":", "List", "[", "int", "]", ",", "token_ids_1", ":", "Optional", "[", "List", "[", "int", "]", "]", "=", "None", ")", "->", "List", "[", "int", "]", ":", "sep", "=", "[",...
[ 283, 4 ]
[ 312, 91 ]
python
en
['en', 'error', 'th']
False
create_learning_rate_scheduler
( factors="constant * linear_warmup * rsqrt_decay", base_learning_rate=0.5, warmup_steps=1000, decay_factor=0.5, steps_per_decay=20000, steps_per_cycle=100000, )
Creates learning rate schedule. Interprets factors in the factors string which can consist of: * constant: interpreted as the constant value, * linear_warmup: interpreted as linear warmup until warmup_steps, * rsqrt_decay: divide by square root of max(step, warmup_steps) * rsqrt_normalized_decay: di...
Creates learning rate schedule. Interprets factors in the factors string which can consist of: * constant: interpreted as the constant value, * linear_warmup: interpreted as linear warmup until warmup_steps, * rsqrt_decay: divide by square root of max(step, warmup_steps) * rsqrt_normalized_decay: di...
def create_learning_rate_scheduler( factors="constant * linear_warmup * rsqrt_decay", base_learning_rate=0.5, warmup_steps=1000, decay_factor=0.5, steps_per_decay=20000, steps_per_cycle=100000, ): """Creates learning rate schedule. Interprets factors in the factors string which can consi...
[ "def", "create_learning_rate_scheduler", "(", "factors", "=", "\"constant * linear_warmup * rsqrt_decay\"", ",", "base_learning_rate", "=", "0.5", ",", "warmup_steps", "=", "1000", ",", "decay_factor", "=", "0.5", ",", "steps_per_decay", "=", "20000", ",", "steps_per_cy...
[ 276, 0 ]
[ 327, 18 ]
python
en
['en', 'en', 'en']
True
compute_metrics
(logits, labels, weights, label_smoothing=0.0)
Compute summary metrics.
Compute summary metrics.
def compute_metrics(logits, labels, weights, label_smoothing=0.0): """Compute summary metrics.""" loss, normalizer = cross_entropy(logits, labels, weights, label_smoothing) acc, _ = accuracy(logits, labels, weights) metrics = {"loss": loss, "accuracy": acc, "normalizer": normalizer} metrics = jax.la...
[ "def", "compute_metrics", "(", "logits", ",", "labels", ",", "weights", ",", "label_smoothing", "=", "0.0", ")", ":", "loss", ",", "normalizer", "=", "cross_entropy", "(", "logits", ",", "labels", ",", "weights", ",", "label_smoothing", ")", "acc", ",", "_...
[ 330, 0 ]
[ 336, 18 ]
python
en
['en', 'et', 'en']
True
accuracy
(logits, targets, weights=None)
Compute weighted accuracy for log probs and targets. Args: logits: [batch, length, num_classes] float array. targets: categorical targets [batch, length] int array. weights: None or array of shape [batch, length] Returns: Tuple of scalar loss and batch normalizing factor.
Compute weighted accuracy for log probs and targets. Args: logits: [batch, length, num_classes] float array. targets: categorical targets [batch, length] int array. weights: None or array of shape [batch, length] Returns: Tuple of scalar loss and batch normalizing factor.
def accuracy(logits, targets, weights=None): """Compute weighted accuracy for log probs and targets. Args: logits: [batch, length, num_classes] float array. targets: categorical targets [batch, length] int array. weights: None or array of shape [batch, length] Returns: Tuple of scalar l...
[ "def", "accuracy", "(", "logits", ",", "targets", ",", "weights", "=", "None", ")", ":", "if", "logits", ".", "ndim", "!=", "targets", ".", "ndim", "+", "1", ":", "raise", "ValueError", "(", "\"Incorrect shapes. Got shape %s logits and %s targets\"", "%", "(",...
[ 339, 0 ]
[ 356, 36 ]
python
en
['en', 'en', 'en']
True
cross_entropy
(logits, targets, weights=None, label_smoothing=0.0)
Compute cross entropy and entropy for log probs and targets. Args: logits: [batch, length, num_classes] float array. targets: categorical targets [batch, length] int array. weights: None or array of shape [batch, length] label_smoothing: label smoothing constant, used to determine the on and off...
Compute cross entropy and entropy for log probs and targets. Args: logits: [batch, length, num_classes] float array. targets: categorical targets [batch, length] int array. weights: None or array of shape [batch, length] label_smoothing: label smoothing constant, used to determine the on and off...
def cross_entropy(logits, targets, weights=None, label_smoothing=0.0): """Compute cross entropy and entropy for log probs and targets. Args: logits: [batch, length, num_classes] float array. targets: categorical targets [batch, length] int array. weights: None or array of shape [batch, length] ...
[ "def", "cross_entropy", "(", "logits", ",", "targets", ",", "weights", "=", "None", ",", "label_smoothing", "=", "0.0", ")", ":", "if", "logits", ".", "ndim", "!=", "targets", ".", "ndim", "+", "1", ":", "raise", "ValueError", "(", "\"Incorrect shapes. Got...
[ 359, 0 ]
[ 391, 41 ]
python
en
['en', 'en', 'en']
True
eval_step
(params, batch)
Calculate evaluation metrics on a batch.
Calculate evaluation metrics on a batch.
def eval_step(params, batch): """ Calculate evaluation metrics on a batch. """ targets = batch.pop("labels") # Hide away tokens which doesn't participate in the optimization token_mask = jnp.where(targets > 0, 1.0, 0.0) logits = model(**batch, params=params, train=False)[0] return comp...
[ "def", "eval_step", "(", "params", ",", "batch", ")", ":", "targets", "=", "batch", ".", "pop", "(", "\"labels\"", ")", "# Hide away tokens which doesn't participate in the optimization", "token_mask", "=", "jnp", ".", "where", "(", "targets", ">", "0", ",", "1....
[ 417, 0 ]
[ 427, 55 ]
python
en
['en', 'error', 'th']
False
get_service
(hass, config, discovery_info=None)
Get the Mastodon notification service.
Get the Mastodon notification service.
def get_service(hass, config, discovery_info=None): """Get the Mastodon notification service.""" client_id = config.get(CONF_CLIENT_ID) client_secret = config.get(CONF_CLIENT_SECRET) access_token = config.get(CONF_ACCESS_TOKEN) base_url = config.get(CONF_BASE_URL) try: mastodon = Mastod...
[ "def", "get_service", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "client_id", "=", "config", ".", "get", "(", "CONF_CLIENT_ID", ")", "client_secret", "=", "config", ".", "get", "(", "CONF_CLIENT_SECRET", ")", "access_token", "=...
[ 27, 0 ]
[ 46, 48 ]
python
en
['en', 'fi', 'en']
True
MastodonNotificationService.__init__
(self, api)
Initialize the service.
Initialize the service.
def __init__(self, api): """Initialize the service.""" self._api = api
[ "def", "__init__", "(", "self", ",", "api", ")", ":", "self", ".", "_api", "=", "api" ]
[ 52, 4 ]
[ 54, 23 ]
python
en
['en', 'en', 'en']
True
MastodonNotificationService.send_message
(self, message="", **kwargs)
Send a message to a user.
Send a message to a user.
def send_message(self, message="", **kwargs): """Send a message to a user.""" try: self._api.toot(message) except MastodonAPIError: _LOGGER.error("Unable to send message")
[ "def", "send_message", "(", "self", ",", "message", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "try", ":", "self", ".", "_api", ".", "toot", "(", "message", ")", "except", "MastodonAPIError", ":", "_LOGGER", ".", "error", "(", "\"Unable to send mess...
[ 56, 4 ]
[ 61, 51 ]
python
en
['en', 'en', 'en']
True
TestHoneywell.test_setup_us
(self, mock_ht, mock_sc)
Test for the US setup.
Test for the US setup.
def test_setup_us(self, mock_ht, mock_sc): """Test for the US setup.""" config = { CONF_USERNAME: "user", CONF_PASSWORD: "pass", honeywell.CONF_REGION: "us", } bad_pass_config = {CONF_USERNAME: "user", honeywell.CONF_REGION: "us"} bad_region_co...
[ "def", "test_setup_us", "(", "self", ",", "mock_ht", ",", "mock_sc", ")", ":", "config", "=", "{", "CONF_USERNAME", ":", "\"user\"", ",", "CONF_PASSWORD", ":", "\"pass\"", ",", "honeywell", ".", "CONF_REGION", ":", "\"us\"", ",", "}", "bad_pass_config", "=",...
[ 30, 4 ]
[ 76, 9 ]
python
en
['en', 'en', 'en']
True
TestHoneywell.test_setup_us_failures
(self, mock_sc)
Test the US setup.
Test the US setup.
def test_setup_us_failures(self, mock_sc): """Test the US setup.""" hass = mock.MagicMock() add_entities = mock.MagicMock() config = { CONF_USERNAME: "user", CONF_PASSWORD: "pass", honeywell.CONF_REGION: "us", } mock_sc.side_effect = s...
[ "def", "test_setup_us_failures", "(", "self", ",", "mock_sc", ")", ":", "hass", "=", "mock", ".", "MagicMock", "(", ")", "add_entities", "=", "mock", ".", "MagicMock", "(", ")", "config", "=", "{", "CONF_USERNAME", ":", "\"user\"", ",", "CONF_PASSWORD", ":...
[ 79, 4 ]
[ 97, 38 ]
python
en
['en', 'haw', 'en']
True
TestHoneywell._test_us_filtered_devices
(self, mock_ht, mock_sc, loc=None, dev=None)
Test for US filtered thermostats.
Test for US filtered thermostats.
def _test_us_filtered_devices(self, mock_ht, mock_sc, loc=None, dev=None): """Test for US filtered thermostats.""" config = { CONF_USERNAME: "user", CONF_PASSWORD: "pass", honeywell.CONF_REGION: "us", "location": loc, "thermostat": dev, ...
[ "def", "_test_us_filtered_devices", "(", "self", ",", "mock_ht", ",", "mock_sc", ",", "loc", "=", "None", ",", "dev", "=", "None", ")", ":", "config", "=", "{", "CONF_USERNAME", ":", "\"user\"", ",", "CONF_PASSWORD", ":", "\"pass\"", ",", "honeywell", ".",...
[ 101, 4 ]
[ 132, 46 ]
python
en
['en', 'en', 'en']
True
TestHoneywell.test_us_filtered_thermostat_1
(self)
Test for US filtered thermostats.
Test for US filtered thermostats.
def test_us_filtered_thermostat_1(self): """Test for US filtered thermostats.""" result, client = self._test_us_filtered_devices(dev=mock.sentinel.loc1dev1) devices = [x[0][1].deviceid for x in result] assert [mock.sentinel.loc1dev1] == devices
[ "def", "test_us_filtered_thermostat_1", "(", "self", ")", ":", "result", ",", "client", "=", "self", ".", "_test_us_filtered_devices", "(", "dev", "=", "mock", ".", "sentinel", ".", "loc1dev1", ")", "devices", "=", "[", "x", "[", "0", "]", "[", "1", "]",...
[ 134, 4 ]
[ 138, 50 ]
python
en
['en', 'en', 'en']
True
TestHoneywell.test_us_filtered_thermostat_2
(self)
Test for US filtered location.
Test for US filtered location.
def test_us_filtered_thermostat_2(self): """Test for US filtered location.""" result, client = self._test_us_filtered_devices(dev=mock.sentinel.loc2dev1) devices = [x[0][1].deviceid for x in result] assert [mock.sentinel.loc2dev1] == devices
[ "def", "test_us_filtered_thermostat_2", "(", "self", ")", ":", "result", ",", "client", "=", "self", ".", "_test_us_filtered_devices", "(", "dev", "=", "mock", ".", "sentinel", ".", "loc2dev1", ")", "devices", "=", "[", "x", "[", "0", "]", "[", "1", "]",...
[ 140, 4 ]
[ 144, 50 ]
python
en
['en', 'en', 'en']
True
TestHoneywell.test_us_filtered_location_1
(self)
Test for US filtered locations.
Test for US filtered locations.
def test_us_filtered_location_1(self): """Test for US filtered locations.""" result, client = self._test_us_filtered_devices(loc=mock.sentinel.loc1) devices = [x[0][1].deviceid for x in result] assert [mock.sentinel.loc1dev1, mock.sentinel.loc1dev2] == devices
[ "def", "test_us_filtered_location_1", "(", "self", ")", ":", "result", ",", "client", "=", "self", ".", "_test_us_filtered_devices", "(", "loc", "=", "mock", ".", "sentinel", ".", "loc1", ")", "devices", "=", "[", "x", "[", "0", "]", "[", "1", "]", "."...
[ 146, 4 ]
[ 150, 74 ]
python
en
['en', 'en', 'en']
True
TestHoneywell.test_us_filtered_location_2
(self)
Test for US filtered locations.
Test for US filtered locations.
def test_us_filtered_location_2(self): """Test for US filtered locations.""" result, client = self._test_us_filtered_devices(loc=mock.sentinel.loc2) devices = [x[0][1].deviceid for x in result] assert [mock.sentinel.loc2dev1] == devices
[ "def", "test_us_filtered_location_2", "(", "self", ")", ":", "result", ",", "client", "=", "self", ".", "_test_us_filtered_devices", "(", "loc", "=", "mock", ".", "sentinel", ".", "loc2", ")", "devices", "=", "[", "x", "[", "0", "]", "[", "1", "]", "."...
[ 152, 4 ]
[ 156, 50 ]
python
en
['en', 'en', 'en']
True
TestHoneywell.test_eu_setup_full_config
(self, mock_round, mock_evo)
Test the EU setup with complete configuration.
Test the EU setup with complete configuration.
def test_eu_setup_full_config(self, mock_round, mock_evo): """Test the EU setup with complete configuration.""" config = { CONF_USERNAME: "user", CONF_PASSWORD: "pass", honeywell.CONF_REGION: "eu", } mock_evo.return_value.temperatures.return_value = [{...
[ "def", "test_eu_setup_full_config", "(", "self", ",", "mock_round", ",", "mock_evo", ")", ":", "config", "=", "{", "CONF_USERNAME", ":", "\"user\"", ",", "CONF_PASSWORD", ":", "\"pass\"", ",", "honeywell", ".", "CONF_REGION", ":", "\"eu\"", ",", "}", "mock_evo...
[ 160, 4 ]
[ 183, 43 ]
python
en
['en', 'en', 'en']
True
TestHoneywell.test_eu_setup_partial_config
(self, mock_round, mock_evo)
Test the EU setup with partial configuration.
Test the EU setup with partial configuration.
def test_eu_setup_partial_config(self, mock_round, mock_evo): """Test the EU setup with partial configuration.""" config = { CONF_USERNAME: "user", CONF_PASSWORD: "pass", honeywell.CONF_REGION: "eu", } mock_evo.return_value.temperatures.return_value =...
[ "def", "test_eu_setup_partial_config", "(", "self", ",", "mock_round", ",", "mock_evo", ")", ":", "config", "=", "{", "CONF_USERNAME", ":", "\"user\"", ",", "CONF_PASSWORD", ":", "\"pass\"", ",", "honeywell", ".", "CONF_REGION", ":", "\"eu\"", ",", "}", "mock_...
[ 187, 4 ]
[ 205, 9 ]
python
en
['en', 'pt', 'en']
True
TestHoneywell.test_eu_setup_bad_temp
(self, mock_round, mock_evo)
Test the EU setup with invalid temperature.
Test the EU setup with invalid temperature.
def test_eu_setup_bad_temp(self, mock_round, mock_evo): """Test the EU setup with invalid temperature.""" config = { CONF_USERNAME: "user", CONF_PASSWORD: "pass", honeywell.CONF_REGION: "eu", } with pytest.raises(vol.Invalid): honeywell.PL...
[ "def", "test_eu_setup_bad_temp", "(", "self", ",", "mock_round", ",", "mock_evo", ")", ":", "config", "=", "{", "CONF_USERNAME", ":", "\"user\"", ",", "CONF_PASSWORD", ":", "\"pass\"", ",", "honeywell", ".", "CONF_REGION", ":", "\"eu\"", ",", "}", "with", "p...
[ 209, 4 ]
[ 218, 45 ]
python
en
['en', 'sm', 'en']
True
TestHoneywell.test_eu_setup_error
(self, mock_round, mock_evo)
Test the EU setup with errors.
Test the EU setup with errors.
def test_eu_setup_error(self, mock_round, mock_evo): """Test the EU setup with errors.""" config = { CONF_USERNAME: "user", CONF_PASSWORD: "pass", honeywell.CONF_REGION: "eu", } mock_evo.return_value.temperatures.side_effect = ( requests.ex...
[ "def", "test_eu_setup_error", "(", "self", ",", "mock_round", ",", "mock_evo", ")", ":", "config", "=", "{", "CONF_USERNAME", ":", "\"user\"", ",", "CONF_PASSWORD", ":", "\"pass\"", ",", "honeywell", ".", "CONF_REGION", ":", "\"eu\"", ",", "}", "mock_evo", "...
[ 222, 4 ]
[ 234, 71 ]
python
en
['en', 'haw', 'en']
True
TestHoneywellRound.setup_method
(self, method)
Test the setup method.
Test the setup method.
def setup_method(self, method): """Test the setup method.""" def fake_temperatures(force_refresh=None): """Create fake temperatures.""" temps = [ { "id": "1", "temp": 20, "setpoint": 21, ...
[ "def", "setup_method", "(", "self", ",", "method", ")", ":", "def", "fake_temperatures", "(", "force_refresh", "=", "None", ")", ":", "\"\"\"Create fake temperatures.\"\"\"", "temps", "=", "[", "{", "\"id\"", ":", "\"1\"", ",", "\"temp\"", ":", "20", ",", "\...
[ 240, 4 ]
[ 267, 28 ]
python
en
['en', 'et', 'en']
True
TestHoneywellRound.test_attributes
(self)
Test the attributes.
Test the attributes.
def test_attributes(self): """Test the attributes.""" assert "House" == self.round1.name assert TEMP_CELSIUS == self.round1.temperature_unit assert 20 == self.round1.current_temperature assert 21 == self.round1.target_temperature assert not self.round1.is_away_mode_on ...
[ "def", "test_attributes", "(", "self", ")", ":", "assert", "\"House\"", "==", "self", ".", "round1", ".", "name", "assert", "TEMP_CELSIUS", "==", "self", ".", "round1", ".", "temperature_unit", "assert", "20", "==", "self", ".", "round1", ".", "current_tempe...
[ 269, 4 ]
[ 281, 46 ]
python
en
['en', 'en', 'en']
True
TestHoneywellRound.test_away_mode
(self)
Test setting the away mode.
Test setting the away mode.
def test_away_mode(self): """Test setting the away mode.""" assert not self.round1.is_away_mode_on self.round1.turn_away_mode_on() assert self.round1.is_away_mode_on assert self.device.set_temperature.call_count == 1 assert self.device.set_temperature.call_args == mock.ca...
[ "def", "test_away_mode", "(", "self", ")", ":", "assert", "not", "self", ".", "round1", ".", "is_away_mode_on", "self", ".", "round1", ".", "turn_away_mode_on", "(", ")", "assert", "self", ".", "round1", ".", "is_away_mode_on", "assert", "self", ".", "device...
[ 283, 4 ]
[ 295, 79 ]
python
en
['en', 'en', 'en']
True
TestHoneywellRound.test_set_temperature
(self)
Test setting the temperature.
Test setting the temperature.
def test_set_temperature(self): """Test setting the temperature.""" self.round1.set_temperature(temperature=25) assert self.device.set_temperature.call_count == 1 assert self.device.set_temperature.call_args == mock.call("House", 25)
[ "def", "test_set_temperature", "(", "self", ")", ":", "self", ".", "round1", ".", "set_temperature", "(", "temperature", "=", "25", ")", "assert", "self", ".", "device", ".", "set_temperature", ".", "call_count", "==", "1", "assert", "self", ".", "device", ...
[ 297, 4 ]
[ 301, 78 ]
python
en
['en', 'en', 'en']
True
TestHoneywellRound.test_set_hvac_mode
(self)
Test setting the system operation.
Test setting the system operation.
def test_set_hvac_mode(self) -> None: """Test setting the system operation.""" self.round1.set_hvac_mode("cool") assert "cool" == self.round1.current_operation assert "cool" == self.device.system_mode self.round1.set_hvac_mode("heat") assert "heat" == self.round1.current...
[ "def", "test_set_hvac_mode", "(", "self", ")", "->", "None", ":", "self", ".", "round1", ".", "set_hvac_mode", "(", "\"cool\"", ")", "assert", "\"cool\"", "==", "self", ".", "round1", ".", "current_operation", "assert", "\"cool\"", "==", "self", ".", "device...
[ 303, 4 ]
[ 311, 48 ]
python
en
['en', 'en', 'en']
True
TestHoneywellUS.setup_method
(self, method)
Test the setup method.
Test the setup method.
def setup_method(self, method): """Test the setup method.""" self.client = mock.MagicMock() self.device = mock.MagicMock() self.cool_away_temp = 18 self.heat_away_temp = 28 self.honeywell = honeywell.HoneywellUSThermostat( self.client, self.device,...
[ "def", "setup_method", "(", "self", ",", "method", ")", ":", "self", ".", "client", "=", "mock", ".", "MagicMock", "(", ")", "self", ".", "device", "=", "mock", ".", "MagicMock", "(", ")", "self", ".", "cool_away_temp", "=", "18", "self", ".", "heat_...
[ 317, 4 ]
[ 339, 37 ]
python
en
['en', 'et', 'en']
True
TestHoneywellUS.test_properties
(self)
Test the properties.
Test the properties.
def test_properties(self): """Test the properties.""" assert self.honeywell.is_fan_on assert "test" == self.honeywell.name assert 72 == self.honeywell.current_temperature
[ "def", "test_properties", "(", "self", ")", ":", "assert", "self", ".", "honeywell", ".", "is_fan_on", "assert", "\"test\"", "==", "self", ".", "honeywell", ".", "name", "assert", "72", "==", "self", ".", "honeywell", ".", "current_temperature" ]
[ 341, 4 ]
[ 345, 55 ]
python
en
['en', 'en', 'en']
True
TestHoneywellUS.test_unit_of_measurement
(self)
Test the unit of measurement.
Test the unit of measurement.
def test_unit_of_measurement(self): """Test the unit of measurement.""" assert TEMP_FAHRENHEIT == self.honeywell.temperature_unit self.device.temperature_unit = "C" assert TEMP_CELSIUS == self.honeywell.temperature_unit
[ "def", "test_unit_of_measurement", "(", "self", ")", ":", "assert", "TEMP_FAHRENHEIT", "==", "self", ".", "honeywell", ".", "temperature_unit", "self", ".", "device", ".", "temperature_unit", "=", "\"C\"", "assert", "TEMP_CELSIUS", "==", "self", ".", "honeywell", ...
[ 347, 4 ]
[ 351, 62 ]
python
en
['en', 'fr', 'en']
True
TestHoneywellUS.test_target_temp
(self)
Test the target temperature.
Test the target temperature.
def test_target_temp(self): """Test the target temperature.""" assert 65 == self.honeywell.target_temperature self.device.system_mode = "cool" assert 78 == self.honeywell.target_temperature
[ "def", "test_target_temp", "(", "self", ")", ":", "assert", "65", "==", "self", ".", "honeywell", ".", "target_temperature", "self", ".", "device", ".", "system_mode", "=", "\"cool\"", "assert", "78", "==", "self", ".", "honeywell", ".", "target_temperature" ]
[ 353, 4 ]
[ 357, 54 ]
python
en
['en', 'la', 'en']
True
TestHoneywellUS.test_set_temp
(self)
Test setting the temperature.
Test setting the temperature.
def test_set_temp(self): """Test setting the temperature.""" self.honeywell.set_temperature(temperature=70) assert 70 == self.device.setpoint_heat assert 70 == self.honeywell.target_temperature self.device.system_mode = "cool" assert 78 == self.honeywell.target_temperatu...
[ "def", "test_set_temp", "(", "self", ")", ":", "self", ".", "honeywell", ".", "set_temperature", "(", "temperature", "=", "70", ")", "assert", "70", "==", "self", ".", "device", ".", "setpoint_heat", "assert", "70", "==", "self", ".", "honeywell", ".", "...
[ 359, 4 ]
[ 369, 54 ]
python
en
['en', 'en', 'en']
True
TestHoneywellUS.test_set_hvac_mode
(self)
Test setting the operation mode.
Test setting the operation mode.
def test_set_hvac_mode(self) -> None: """Test setting the operation mode.""" self.honeywell.set_hvac_mode("cool") assert "cool" == self.device.system_mode self.honeywell.set_hvac_mode("heat") assert "heat" == self.device.system_mode
[ "def", "test_set_hvac_mode", "(", "self", ")", "->", "None", ":", "self", ".", "honeywell", ".", "set_hvac_mode", "(", "\"cool\"", ")", "assert", "\"cool\"", "==", "self", ".", "device", ".", "system_mode", "self", ".", "honeywell", ".", "set_hvac_mode", "("...
[ 371, 4 ]
[ 377, 48 ]
python
en
['en', 'en', 'en']
True
TestHoneywellUS.test_set_temp_fail
(self)
Test if setting the temperature fails.
Test if setting the temperature fails.
def test_set_temp_fail(self): """Test if setting the temperature fails.""" self.device.setpoint_heat = mock.MagicMock( side_effect=somecomfort.SomeComfortError ) self.honeywell.set_temperature(temperature=123)
[ "def", "test_set_temp_fail", "(", "self", ")", ":", "self", ".", "device", ".", "setpoint_heat", "=", "mock", ".", "MagicMock", "(", "side_effect", "=", "somecomfort", ".", "SomeComfortError", ")", "self", ".", "honeywell", ".", "set_temperature", "(", "temper...
[ 379, 4 ]
[ 384, 55 ]
python
en
['en', 'en', 'en']
True
TestHoneywellUS.test_attributes
(self)
Test the attributes.
Test the attributes.
def test_attributes(self): """Test the attributes.""" expected = { honeywell.ATTR_FAN: "running", ATTR_FAN_MODE: "auto", ATTR_FAN_MODES: somecomfort.FAN_MODES, ATTR_HVAC_MODES: somecomfort.SYSTEM_MODES, } assert expected == self.honeywell.d...
[ "def", "test_attributes", "(", "self", ")", ":", "expected", "=", "{", "honeywell", ".", "ATTR_FAN", ":", "\"running\"", ",", "ATTR_FAN_MODE", ":", "\"auto\"", ",", "ATTR_FAN_MODES", ":", "somecomfort", ".", "FAN_MODES", ",", "ATTR_HVAC_MODES", ":", "somecomfort...
[ 386, 4 ]
[ 397, 65 ]
python
en
['en', 'en', 'en']
True
TestHoneywellUS.test_with_no_fan
(self)
Test if there is on fan.
Test if there is on fan.
def test_with_no_fan(self): """Test if there is on fan.""" self.device.fan_running = False self.device.fan_mode = None expected = { honeywell.ATTR_FAN: "idle", ATTR_FAN_MODE: None, ATTR_FAN_MODES: somecomfort.FAN_MODES, ATTR_HVAC_MODES: som...
[ "def", "test_with_no_fan", "(", "self", ")", ":", "self", ".", "device", ".", "fan_running", "=", "False", "self", ".", "device", ".", "fan_mode", "=", "None", "expected", "=", "{", "honeywell", ".", "ATTR_FAN", ":", "\"idle\"", ",", "ATTR_FAN_MODE", ":", ...
[ 399, 4 ]
[ 409, 65 ]
python
en
['en', 'en', 'en']
True
TestHoneywellUS.test_heat_away_mode
(self)
Test setting the heat away mode.
Test setting the heat away mode.
def test_heat_away_mode(self): """Test setting the heat away mode.""" self.honeywell.set_hvac_mode("heat") assert not self.honeywell.is_away_mode_on self.honeywell.turn_away_mode_on() assert self.honeywell.is_away_mode_on assert self.device.setpoint_heat == self.heat_away...
[ "def", "test_heat_away_mode", "(", "self", ")", ":", "self", ".", "honeywell", ".", "set_hvac_mode", "(", "\"heat\"", ")", "assert", "not", "self", ".", "honeywell", ".", "is_away_mode_on", "self", ".", "honeywell", ".", "turn_away_mode_on", "(", ")", "assert"...
[ 411, 4 ]
[ 422, 45 ]
python
en
['en', 'en', 'en']
True
TestHoneywellUS.test_retry
(self, test_somecomfort)
Test retry connection.
Test retry connection.
def test_retry(self, test_somecomfort): """Test retry connection.""" old_device = self.honeywell._device self.honeywell._retry() assert self.honeywell._device == old_device
[ "def", "test_retry", "(", "self", ",", "test_somecomfort", ")", ":", "old_device", "=", "self", ".", "honeywell", ".", "_device", "self", ".", "honeywell", ".", "_retry", "(", ")", "assert", "self", ".", "honeywell", ".", "_device", "==", "old_device" ]
[ 425, 4 ]
[ 429, 51 ]
python
en
['en', 'en', 'en']
True
get_scanner
(hass, config)
Validate the configuration and return a Unifi direct scanner.
Validate the configuration and return a Unifi direct scanner.
def get_scanner(hass, config): """Validate the configuration and return a Unifi direct scanner.""" scanner = UnifiDeviceScanner(config[DOMAIN]) if not scanner.connected: return False return scanner
[ "def", "get_scanner", "(", "hass", ",", "config", ")", ":", "scanner", "=", "UnifiDeviceScanner", "(", "config", "[", "DOMAIN", "]", ")", "if", "not", "scanner", ".", "connected", ":", "return", "False", "return", "scanner" ]
[ 32, 0 ]
[ 37, 18 ]
python
en
['en', 'en', 'en']
True
UnifiDeviceScanner.__init__
(self, config)
Initialize the scanner.
Initialize the scanner.
def __init__(self, config): """Initialize the scanner.""" self.host = config[CONF_HOST] self.username = config[CONF_USERNAME] self.password = config[CONF_PASSWORD] self.port = config[CONF_PORT] self.ssh = None self.connected = False self.last_results = {} ...
[ "def", "__init__", "(", "self", ",", "config", ")", ":", "self", ".", "host", "=", "config", "[", "CONF_HOST", "]", "self", ".", "username", "=", "config", "[", "CONF_USERNAME", "]", "self", ".", "password", "=", "config", "[", "CONF_PASSWORD", "]", "s...
[ 43, 4 ]
[ 52, 23 ]
python
en
['en', 'en', 'en']
True
UnifiDeviceScanner.scan_devices
(self)
Scan for new devices and return a list with found device IDs.
Scan for new devices and return a list with found device IDs.
def scan_devices(self): """Scan for new devices and return a list with found device IDs.""" result = _response_to_json(self._get_update()) if result: self.last_results = result return self.last_results.keys()
[ "def", "scan_devices", "(", "self", ")", ":", "result", "=", "_response_to_json", "(", "self", ".", "_get_update", "(", ")", ")", "if", "result", ":", "self", ".", "last_results", "=", "result", "return", "self", ".", "last_results", ".", "keys", "(", ")...
[ 54, 4 ]
[ 59, 39 ]
python
en
['en', 'en', 'en']
True
UnifiDeviceScanner.get_device_name
(self, device)
Return the name of the given device or None if we don't know.
Return the name of the given device or None if we don't know.
def get_device_name(self, device): """Return the name of the given device or None if we don't know.""" hostname = next( ( value.get("hostname") for key, value in self.last_results.items() if key.upper() == device.upper() ), ...
[ "def", "get_device_name", "(", "self", ",", "device", ")", ":", "hostname", "=", "next", "(", "(", "value", ".", "get", "(", "\"hostname\"", ")", "for", "key", ",", "value", "in", "self", ".", "last_results", ".", "items", "(", ")", "if", "key", ".",...
[ 61, 4 ]
[ 73, 23 ]
python
en
['en', 'en', 'en']
True
UnifiDeviceScanner._connect
(self)
Connect to the Unifi AP SSH server.
Connect to the Unifi AP SSH server.
def _connect(self): """Connect to the Unifi AP SSH server.""" self.ssh = pxssh.pxssh() try: self.ssh.login( self.host, self.username, password=self.password, port=self.port ) self.connected = True except exceptions.EOF: _LO...
[ "def", "_connect", "(", "self", ")", ":", "self", ".", "ssh", "=", "pxssh", ".", "pxssh", "(", ")", "try", ":", "self", ".", "ssh", ".", "login", "(", "self", ".", "host", ",", "self", ".", "username", ",", "password", "=", "self", ".", "password...
[ 75, 4 ]
[ 86, 30 ]
python
en
['en', 'en', 'en']
True
UnifiDeviceScanner._disconnect
(self)
Disconnect the current SSH connection.
Disconnect the current SSH connection.
def _disconnect(self): """Disconnect the current SSH connection.""" try: self.ssh.logout() except Exception: # pylint: disable=broad-except pass finally: self.ssh = None self.connected = False
[ "def", "_disconnect", "(", "self", ")", ":", "try", ":", "self", ".", "ssh", ".", "logout", "(", ")", "except", "Exception", ":", "# pylint: disable=broad-except", "pass", "finally", ":", "self", ".", "ssh", "=", "None", "self", ".", "connected", "=", "F...
[ 88, 4 ]
[ 97, 30 ]
python
en
['en', 'en', 'en']
True
test_send_message_with_data
(hass)
Test sending a message with to a notify group.
Test sending a message with to a notify group.
async def test_send_message_with_data(hass): """Test sending a message with to a notify group.""" service1 = demo.DemoNotificationService(hass) service2 = demo.DemoNotificationService(hass) service1.send_message = MagicMock(autospec=True) service2.send_message = MagicMock(autospec=True) def mo...
[ "async", "def", "test_send_message_with_data", "(", "hass", ")", ":", "service1", "=", "demo", ".", "DemoNotificationService", "(", "hass", ")", "service2", "=", "demo", ".", "DemoNotificationService", "(", "hass", ")", "service1", ".", "send_message", "=", "Mag...
[ 13, 0 ]
[ 79, 5 ]
python
en
['en', 'en', 'en']
True
test_reload_notify
(hass)
Verify we can reload the notify service.
Verify we can reload the notify service.
async def test_reload_notify(hass): """Verify we can reload the notify service.""" assert await async_setup_component( hass, "group", {}, ) await hass.async_block_till_done() assert await async_setup_component( hass, notify.DOMAIN, { noti...
[ "async", "def", "test_reload_notify", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"group\"", ",", "{", "}", ",", ")", "await", "hass", ".", "async_block_till_done", "(", ")", "assert", "await", "async_setup_component", ...
[ 82, 0 ]
[ 130, 71 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the pocketcasts platform for sensors.
Set up the pocketcasts platform for sensors.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the pocketcasts platform for sensors.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) try: api = pocketcasts.Api(username, password) _LOGGER.debug("Found %d podcasts", len(api.my_...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "username", "=", "config", ".", "get", "(", "CONF_USERNAME", ")", "password", "=", "config", ".", "get", "(", "CONF_PASSWORD", ")", "try...
[ 25, 0 ]
[ 36, 20 ]
python
en
['en', 'pt', 'en']
True
PocketCastsSensor.__init__
(self, api)
Initialize the sensor.
Initialize the sensor.
def __init__(self, api): """Initialize the sensor.""" self._api = api self._state = None
[ "def", "__init__", "(", "self", ",", "api", ")", ":", "self", ".", "_api", "=", "api", "self", ".", "_state", "=", "None" ]
[ 42, 4 ]
[ 45, 26 ]
python
en
['en', 'en', 'en']
True
PocketCastsSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return SENSOR_NAME
[ "def", "name", "(", "self", ")", ":", "return", "SENSOR_NAME" ]
[ 48, 4 ]
[ 50, 26 ]
python
en
['en', 'mi', 'en']
True
PocketCastsSensor.state
(self)
Return the sensor state.
Return the sensor state.
def state(self): """Return the sensor state.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 53, 4 ]
[ 55, 26 ]
python
en
['en', 'bs', 'en']
True
PocketCastsSensor.icon
(self)
Return the icon for the sensor.
Return the icon for the sensor.
def icon(self): """Return the icon for the sensor.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 58, 4 ]
[ 60, 19 ]
python
en
['en', 'en', 'en']
True
PocketCastsSensor.update
(self)
Update sensor values.
Update sensor values.
def update(self): """Update sensor values.""" try: self._state = len(self._api.new_episodes_released()) _LOGGER.debug("Found %d new episodes", self._state) except OSError as err: _LOGGER.warning("Failed to contact server: %s", err)
[ "def", "update", "(", "self", ")", ":", "try", ":", "self", ".", "_state", "=", "len", "(", "self", ".", "_api", ".", "new_episodes_released", "(", ")", ")", "_LOGGER", ".", "debug", "(", "\"Found %d new episodes\"", ",", "self", ".", "_state", ")", "e...
[ 62, 4 ]
[ 68, 64 ]
python
en
['en', 'nl', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the IP Webcam Sensor.
Set up the IP Webcam Sensor.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the IP Webcam Sensor.""" if discovery_info is None: return host = discovery_info[CONF_HOST] name = discovery_info[CONF_NAME] sensors = discovery_info[CONF_SENSORS] ipcam = hass.data[DATA_IP_...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "host", "=", "discovery_info", "[", "CONF_HOST", "]", "name", "=",...
[ 14, 0 ]
[ 29, 41 ]
python
en
['en', 'da', 'en']
True
IPWebcamSensor.__init__
(self, name, host, ipcam, sensor)
Initialize the sensor.
Initialize the sensor.
def __init__(self, name, host, ipcam, sensor): """Initialize the sensor.""" super().__init__(host, ipcam) self._sensor = sensor self._mapped_name = KEY_MAP.get(self._sensor, self._sensor) self._name = f"{name} {self._mapped_name}" self._state = None self._unit = ...
[ "def", "__init__", "(", "self", ",", "name", ",", "host", ",", "ipcam", ",", "sensor", ")", ":", "super", "(", ")", ".", "__init__", "(", "host", ",", "ipcam", ")", "self", ".", "_sensor", "=", "sensor", "self", ".", "_mapped_name", "=", "KEY_MAP", ...
[ 35, 4 ]
[ 43, 25 ]
python
en
['en', 'en', 'en']
True