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
pad_physical_address
(addr)
Right-pad a physical address.
Right-pad a physical address.
def pad_physical_address(addr): """Right-pad a physical address.""" return addr + [0] * (4 - len(addr))
[ "def", "pad_physical_address", "(", "addr", ")", ":", "return", "addr", "+", "[", "0", "]", "*", "(", "4", "-", "len", "(", "addr", ")", ")" ]
[ 169, 0 ]
[ 171, 39 ]
python
en
['en', 'en', 'en']
True
parse_mapping
(mapping, parents=None)
Parse configuration device mapping.
Parse configuration device mapping.
def parse_mapping(mapping, parents=None): """Parse configuration device mapping.""" if parents is None: parents = [] for addr, val in mapping.items(): if isinstance(addr, (str,)) and isinstance(val, (str,)): yield (addr, PhysicalAddress(val)) else: cur = paren...
[ "def", "parse_mapping", "(", "mapping", ",", "parents", "=", "None", ")", ":", "if", "parents", "is", "None", ":", "parents", "=", "[", "]", "for", "addr", ",", "val", "in", "mapping", ".", "items", "(", ")", ":", "if", "isinstance", "(", "addr", "...
[ 174, 0 ]
[ 186, 54 ]
python
en
['fr', 'en', 'en']
True
setup
(hass: HomeAssistant, base_config)
Set up the CEC capability.
Set up the CEC capability.
def setup(hass: HomeAssistant, base_config): """Set up the CEC capability.""" # Parse configuration into a dict of device name to physical address # represented as a list of four elements. device_aliases = {} devices = base_config[DOMAIN].get(CONF_DEVICES, {}) _LOGGER.debug("Parsing config %s",...
[ "def", "setup", "(", "hass", ":", "HomeAssistant", ",", "base_config", ")", ":", "# Parse configuration into a dict of device name to physical address", "# represented as a list of four elements.", "device_aliases", "=", "{", "}", "devices", "=", "base_config", "[", "DOMAIN",...
[ 189, 0 ]
[ 356, 15 ]
python
en
['en', 'en', 'en']
True
CecEntity.__init__
(self, device, logical)
Initialize the device.
Initialize the device.
def __init__(self, device, logical) -> None: """Initialize the device.""" self._device = device self._icon = None self._state = None self._logical_address = logical self.entity_id = "%s.%d" % (DOMAIN, self._logical_address)
[ "def", "__init__", "(", "self", ",", "device", ",", "logical", ")", "->", "None", ":", "self", ".", "_device", "=", "device", "self", ".", "_icon", "=", "None", "self", ".", "_state", "=", "None", "self", ".", "_logical_address", "=", "logical", "self"...
[ 362, 4 ]
[ 368, 66 ]
python
en
['en', 'en', 'en']
True
CecEntity.update
(self)
Update device status.
Update device status.
def update(self): """Update device status.""" device = self._device if device.power_status in [POWER_OFF, 3]: self._state = STATE_OFF elif device.status == STATUS_PLAY: self._state = STATE_PLAYING elif device.status == STATUS_STOP: self._state ...
[ "def", "update", "(", "self", ")", ":", "device", "=", "self", ".", "_device", "if", "device", ".", "power_status", "in", "[", "POWER_OFF", ",", "3", "]", ":", "self", ".", "_state", "=", "STATE_OFF", "elif", "device", ".", "status", "==", "STATUS_PLAY...
[ 370, 4 ]
[ 384, 69 ]
python
en
['fr', 'sn', 'en']
False
CecEntity.async_added_to_hass
(self)
Register HDMI callbacks after initialization.
Register HDMI callbacks after initialization.
async def async_added_to_hass(self): """Register HDMI callbacks after initialization.""" self._device.set_update_callback(self._update)
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "_device", ".", "set_update_callback", "(", "self", ".", "_update", ")" ]
[ 386, 4 ]
[ 388, 54 ]
python
en
['da', 'en', 'en']
True
CecEntity._update
(self, device=None)
Device status changed, schedule an update.
Device status changed, schedule an update.
def _update(self, device=None): """Device status changed, schedule an update.""" self.schedule_update_ha_state(True)
[ "def", "_update", "(", "self", ",", "device", "=", "None", ")", ":", "self", ".", "schedule_update_ha_state", "(", "True", ")" ]
[ 390, 4 ]
[ 392, 43 ]
python
en
['de', 'en', 'en']
True
CecEntity.should_poll
(self)
Return false. CecEntity.update() is called by the HDMI network when there is new data.
Return false.
def should_poll(self): """ Return false. CecEntity.update() is called by the HDMI network when there is new data. """ return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 395, 4 ]
[ 401, 20 ]
python
en
['en', 'error', 'th']
False
CecEntity.name
(self)
Return the name of the device.
Return the name of the device.
def name(self): """Return the name of the device.""" return ( f"{self.vendor_name} {self._device.osd_name}" if ( self._device.osd_name is not None and self.vendor_name is not None and self.vendor_name != "Unknown" ) ...
[ "def", "name", "(", "self", ")", ":", "return", "(", "f\"{self.vendor_name} {self._device.osd_name}\"", "if", "(", "self", ".", "_device", ".", "osd_name", "is", "not", "None", "and", "self", ".", "vendor_name", "is", "not", "None", "and", "self", ".", "vend...
[ 404, 4 ]
[ 417, 9 ]
python
en
['en', 'en', 'en']
True
CecEntity.vendor_id
(self)
Return the ID of the device's vendor.
Return the ID of the device's vendor.
def vendor_id(self): """Return the ID of the device's vendor.""" return self._device.vendor_id
[ "def", "vendor_id", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "vendor_id" ]
[ 420, 4 ]
[ 422, 37 ]
python
en
['en', 'en', 'en']
True
CecEntity.vendor_name
(self)
Return the name of the device's vendor.
Return the name of the device's vendor.
def vendor_name(self): """Return the name of the device's vendor.""" return self._device.vendor
[ "def", "vendor_name", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "vendor" ]
[ 425, 4 ]
[ 427, 34 ]
python
en
['en', 'en', 'en']
True
CecEntity.physical_address
(self)
Return the physical address of device in HDMI network.
Return the physical address of device in HDMI network.
def physical_address(self): """Return the physical address of device in HDMI network.""" return str(self._device.physical_address)
[ "def", "physical_address", "(", "self", ")", ":", "return", "str", "(", "self", ".", "_device", ".", "physical_address", ")" ]
[ 430, 4 ]
[ 432, 49 ]
python
en
['en', 'en', 'en']
True
CecEntity.type
(self)
Return a string representation of the device's type.
Return a string representation of the device's type.
def type(self): """Return a string representation of the device's type.""" return self._device.type_name
[ "def", "type", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "type_name" ]
[ 435, 4 ]
[ 437, 37 ]
python
en
['en', 'en', 'en']
True
CecEntity.type_id
(self)
Return the type ID of device.
Return the type ID of device.
def type_id(self): """Return the type ID of device.""" return self._device.type
[ "def", "type_id", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "type" ]
[ 440, 4 ]
[ 442, 32 ]
python
en
['en', 'en', 'en']
True
CecEntity.icon
(self)
Return the icon for device by its type.
Return the icon for device by its type.
def icon(self): """Return the icon for device by its type.""" return ( self._icon if self._icon is not None else ICONS_BY_TYPE.get(self._device.type) if self._device.type in ICONS_BY_TYPE else ICON_UNKNOWN )
[ "def", "icon", "(", "self", ")", ":", "return", "(", "self", ".", "_icon", "if", "self", ".", "_icon", "is", "not", "None", "else", "ICONS_BY_TYPE", ".", "get", "(", "self", ".", "_device", ".", "type", ")", "if", "self", ".", "_device", ".", "type...
[ 445, 4 ]
[ 453, 9 ]
python
en
['en', 'en', 'en']
True
CecEntity.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" state_attr = {} if self.vendor_id is not None: state_attr[ATTR_VENDOR_ID] = self.vendor_id state_attr[ATTR_VENDOR_NAME] = self.vendor_name if self.type_id is not None: state_attr[ATT...
[ "def", "device_state_attributes", "(", "self", ")", ":", "state_attr", "=", "{", "}", "if", "self", ".", "vendor_id", "is", "not", "None", ":", "state_attr", "[", "ATTR_VENDOR_ID", "]", "=", "self", ".", "vendor_id", "state_attr", "[", "ATTR_VENDOR_NAME", "]...
[ 456, 4 ]
[ 467, 25 ]
python
en
['en', 'en', 'en']
True
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...
[ 261, 0 ]
[ 312, 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", ",", "_...
[ 315, 0 ]
[ 321, 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\"", "%", "(",...
[ 324, 0 ]
[ 341, 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...
[ 344, 0 ]
[ 376, 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....
[ 402, 0 ]
[ 412, 55 ]
python
en
['en', 'error', 'th']
False
AutoConfig.from_pretrained
(cls, pretrained_model_name_or_path, **kwargs)
r""" Instantiate one of the configuration classes of the library from a pretrained model configuration. The configuration class to instantiate is selected based on the :obj:`model_type` property of the config object that is loaded, or when it's missing, by falling back to using pattern matching...
r""" Instantiate one of the configuration classes of the library from a pretrained model configuration.
def from_pretrained(cls, pretrained_model_name_or_path, **kwargs): r""" Instantiate one of the configuration classes of the library from a pretrained model configuration. The configuration class to instantiate is selected based on the :obj:`model_type` property of the config object that...
[ "def", "from_pretrained", "(", "cls", ",", "pretrained_model_name_or_path", ",", "*", "*", "kwargs", ")", ":", "config_dict", ",", "_", "=", "PretrainedConfig", ".", "get_config_dict", "(", "pretrained_model_name_or_path", ",", "*", "*", "kwargs", ")", "if", "\"...
[ 311, 4 ]
[ 400, 9 ]
python
cy
['en', 'cy', 'hi']
False
store
(hass)
Mock store.
Mock store.
def store(hass): """Mock store.""" return auth_store.AuthStore(hass)
[ "def", "store", "(", "hass", ")", ":", "return", "auth_store", ".", "AuthStore", "(", "hass", ")" ]
[ 12, 0 ]
[ 14, 37 ]
python
en
['en', 'fy', 'en']
False
provider
(hass, store)
Mock provider.
Mock provider.
def provider(hass, store): """Mock provider.""" return insecure_example.ExampleAuthProvider( hass, store, { "type": "insecure_example", "users": [ { "name": "Test Name", "username": "user-test", ...
[ "def", "provider", "(", "hass", ",", "store", ")", ":", "return", "insecure_example", ".", "ExampleAuthProvider", "(", "hass", ",", "store", ",", "{", "\"type\"", ":", "\"insecure_example\"", ",", "\"users\"", ":", "[", "{", "\"name\"", ":", "\"Test Name\"", ...
[ 18, 0 ]
[ 34, 5 ]
python
en
['en', 'sv', 'en']
False
manager
(hass, store, provider)
Mock manager.
Mock manager.
def manager(hass, store, provider): """Mock manager.""" return AuthManager(hass, store, {(provider.type, provider.id): provider}, {})
[ "def", "manager", "(", "hass", ",", "store", ",", "provider", ")", ":", "return", "AuthManager", "(", "hass", ",", "store", ",", "{", "(", "provider", ".", "type", ",", "provider", ".", "id", ")", ":", "provider", "}", ",", "{", "}", ")" ]
[ 38, 0 ]
[ 40, 81 ]
python
da
['id', 'da', 'en']
False
test_create_new_credential
(manager, provider)
Test that we create a new credential.
Test that we create a new credential.
async def test_create_new_credential(manager, provider): """Test that we create a new credential.""" credentials = await provider.async_get_or_create_credentials( {"username": "user-test", "password": "password-test"} ) assert credentials.is_new is True user = await manager.async_get_or_cre...
[ "async", "def", "test_create_new_credential", "(", "manager", ",", "provider", ")", ":", "credentials", "=", "await", "provider", ".", "async_get_or_create_credentials", "(", "{", "\"username\"", ":", "\"user-test\"", ",", "\"password\"", ":", "\"password-test\"", "}"...
[ 43, 0 ]
[ 52, 25 ]
python
en
['en', 'en', 'en']
True
test_match_existing_credentials
(store, provider)
See if we match existing users.
See if we match existing users.
async def test_match_existing_credentials(store, provider): """See if we match existing users.""" existing = auth_models.Credentials( id=uuid.uuid4(), auth_provider_type="insecure_example", auth_provider_id=None, data={"username": "user-test"}, is_new=False, ) pro...
[ "async", "def", "test_match_existing_credentials", "(", "store", ",", "provider", ")", ":", "existing", "=", "auth_models", ".", "Credentials", "(", "id", "=", "uuid", ".", "uuid4", "(", ")", ",", "auth_provider_type", "=", "\"insecure_example\"", ",", "auth_pro...
[ 55, 0 ]
[ 68, 34 ]
python
en
['en', 'en', 'en']
True
test_verify_username
(provider)
Test we raise if incorrect user specified.
Test we raise if incorrect user specified.
async def test_verify_username(provider): """Test we raise if incorrect user specified.""" with pytest.raises(insecure_example.InvalidAuthError): await provider.async_validate_login("non-existing-user", "password-test")
[ "async", "def", "test_verify_username", "(", "provider", ")", ":", "with", "pytest", ".", "raises", "(", "insecure_example", ".", "InvalidAuthError", ")", ":", "await", "provider", ".", "async_validate_login", "(", "\"non-existing-user\"", ",", "\"password-test\"", ...
[ 71, 0 ]
[ 74, 81 ]
python
en
['en', 'en', 'en']
True
test_verify_password
(provider)
Test we raise if incorrect user specified.
Test we raise if incorrect user specified.
async def test_verify_password(provider): """Test we raise if incorrect user specified.""" with pytest.raises(insecure_example.InvalidAuthError): await provider.async_validate_login("user-test", "incorrect-password")
[ "async", "def", "test_verify_password", "(", "provider", ")", ":", "with", "pytest", ".", "raises", "(", "insecure_example", ".", "InvalidAuthError", ")", ":", "await", "provider", ".", "async_validate_login", "(", "\"user-test\"", ",", "\"incorrect-password\"", ")"...
[ 77, 0 ]
[ 80, 78 ]
python
en
['en', 'en', 'en']
True
test_utf_8_username_password
(provider)
Test that we create a new credential.
Test that we create a new credential.
async def test_utf_8_username_password(provider): """Test that we create a new credential.""" credentials = await provider.async_get_or_create_credentials( {"username": "🎉", "password": "😎"} ) assert credentials.is_new is True
[ "async", "def", "test_utf_8_username_password", "(", "provider", ")", ":", "credentials", "=", "await", "provider", ".", "async_get_or_create_credentials", "(", "{", "\"username\"", ":", "\"🎉\", \"", "p", "ssword\": \"", "😎", "}", "", ")", "assert", "credentials",...
[ 83, 0 ]
[ 88, 37 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Dlib Face detection platform.
Set up the Dlib Face detection platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Dlib Face detection platform.""" entities = [] for camera in config[CONF_SOURCE]: entities.append( DlibFaceDetectEntity(camera[CONF_ENTITY_ID], camera.get(CONF_NAME)) ) add_entities(entities)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "entities", "=", "[", "]", "for", "camera", "in", "config", "[", "CONF_SOURCE", "]", ":", "entities", ".", "append", "(", "DlibFaceDetec...
[ 21, 0 ]
[ 29, 26 ]
python
en
['en', 'da', 'en']
True
DlibFaceDetectEntity.__init__
(self, camera_entity, name=None)
Initialize Dlib face entity.
Initialize Dlib face entity.
def __init__(self, camera_entity, name=None): """Initialize Dlib face entity.""" super().__init__() self._camera = camera_entity if name: self._name = name else: self._name = f"Dlib Face {split_entity_id(camera_entity)[1]}"
[ "def", "__init__", "(", "self", ",", "camera_entity", ",", "name", "=", "None", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "_camera", "=", "camera_entity", "if", "name", ":", "self", ".", "_name", "=", "name", "else", ":", ...
[ 35, 4 ]
[ 44, 73 ]
python
es
['es', 'zu', 'it']
False
DlibFaceDetectEntity.camera_entity
(self)
Return camera entity id from process pictures.
Return camera entity id from process pictures.
def camera_entity(self): """Return camera entity id from process pictures.""" return self._camera
[ "def", "camera_entity", "(", "self", ")", ":", "return", "self", ".", "_camera" ]
[ 47, 4 ]
[ 49, 27 ]
python
en
['en', 'en', 'en']
True
DlibFaceDetectEntity.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self): """Return the name of the entity.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 52, 4 ]
[ 54, 25 ]
python
en
['en', 'en', 'en']
True
DlibFaceDetectEntity.process_image
(self, image)
Process image.
Process image.
def process_image(self, image): """Process image.""" fak_file = io.BytesIO(image) fak_file.name = "snapshot.jpg" fak_file.seek(0) image = face_recognition.load_image_file(fak_file) face_locations = face_recognition.face_locations(image) face_locations = [{ATTR_...
[ "def", "process_image", "(", "self", ",", "image", ")", ":", "fak_file", "=", "io", ".", "BytesIO", "(", "image", ")", "fak_file", ".", "name", "=", "\"snapshot.jpg\"", "fak_file", ".", "seek", "(", "0", ")", "image", "=", "face_recognition", ".", "load_...
[ 56, 4 ]
[ 68, 63 ]
python
en
['en', 'ny', 'en']
False
async_setup_entry
(hass, config_entry, async_add_entities)
Set up a Tradfri config entry.
Set up a Tradfri config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up a Tradfri 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] sensors = ( dev ...
[ "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_...
[ 8, 0 ]
[ 24, 88 ]
python
en
['en', 'pt', 'en']
True
TradfriSensor.__init__
(self, device, api, gateway_id)
Initialize the device.
Initialize the device.
def __init__(self, device, api, gateway_id): """Initialize the device.""" 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}\"" ]
[ 30, 4 ]
[ 33, 53 ]
python
en
['en', 'en', 'en']
True
TradfriSensor.device_class
(self)
Return the devices' state attributes.
Return the devices' state attributes.
def device_class(self): """Return the devices' state attributes.""" return DEVICE_CLASS_BATTERY
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_BATTERY" ]
[ 36, 4 ]
[ 38, 35 ]
python
en
['en', 'en', 'en']
True
TradfriSensor.state
(self)
Return the current state of the device.
Return the current state of the device.
def state(self): """Return the current state of the device.""" return self._device.device_info.battery_level
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "device_info", ".", "battery_level" ]
[ 41, 4 ]
[ 43, 53 ]
python
en
['en', 'en', 'en']
True
TradfriSensor.unit_of_measurement
(self)
Return the unit_of_measurement of the device.
Return the unit_of_measurement of the device.
def unit_of_measurement(self): """Return the unit_of_measurement of the device.""" return PERCENTAGE
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "PERCENTAGE" ]
[ 46, 4 ]
[ 48, 25 ]
python
en
['en', 'en', 'en']
True
CitiBikeILP.__init__
( self, num_station: int, num_neighbor: int, station_capacity: List[int], station_neighbor_list: List[List[int]], decision_interval: int, config: DottableDict )
A simple Linear Programming formulation for solving the bike repositioning problem. Args: num_station (int): Number of stations in current topology. num_neighbor (int): Number of neighbors that needed to consider when repositioning. station_capacity (List[int]): The capacity...
A simple Linear Programming formulation for solving the bike repositioning problem.
def __init__( self, num_station: int, num_neighbor: int, station_capacity: List[int], station_neighbor_list: List[List[int]], decision_interval: int, config: DottableDict ): """A simple Linear Programming formulation for solving the bike repositioning problem. Args: ...
[ "def", "__init__", "(", "self", ",", "num_station", ":", "int", ",", "num_neighbor", ":", "int", ",", "station_capacity", ":", "List", "[", "int", "]", ",", "station_neighbor_list", ":", "List", "[", "List", "[", "int", "]", "]", ",", "decision_interval", ...
[ 10, 4 ]
[ 47, 34 ]
python
en
['en', 'en', 'en']
True
CitiBikeILP.get_transfer_list
( self, env_tick: int, init_inventory: np.ndarray, demand: np.ndarray, supply: np.ndarray )
Get the transfer list for the given env_tick. Args: env_tick (int): The environment tick when calling this function. init_inventory (np.ndarray): The initial inventory of each station. Shape: (num_station). demand (np.ndarray): The demand for each station in ...
Get the transfer list for the given env_tick.
def get_transfer_list( self, env_tick: int, init_inventory: np.ndarray, demand: np.ndarray, supply: np.ndarray ) -> List[Tuple[int, int, int]]: """Get the transfer list for the given env_tick. Args: env_tick (int): The environment tick when calling this function. ini...
[ "def", "get_transfer_list", "(", "self", ",", "env_tick", ":", "int", ",", "init_inventory", ":", "np", ".", "ndarray", ",", "demand", ":", "np", ".", "ndarray", ",", "supply", ":", "np", ".", "ndarray", ")", "->", "List", "[", "Tuple", "[", "int", "...
[ 182, 4 ]
[ 215, 28 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, platform)
Set up the TotalConnect platform.
Set up the TotalConnect platform.
async def setup_platform(hass, platform): """Set up the TotalConnect platform.""" # first set up a config entry and add it to hass mock_entry = MockConfigEntry( domain=DOMAIN, data={CONF_USERNAME: "user@email.com", CONF_PASSWORD: "password"}, ) mock_entry.add_to_hass(hass) respo...
[ "async", "def", "setup_platform", "(", "hass", ",", "platform", ")", ":", "# first set up a config entry and add it to hass", "mock_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "{", "CONF_USERNAME", ":", "\"user@email.com\"", ",", ...
[ 104, 0 ]
[ 128, 21 ]
python
en
['en', 'da', 'en']
True
BaseCrawler.crawl
(self)
crawl main method
crawl main method
def crawl(self): """ crawl main method """ for url in self.urls: logger.info(f'fetching {url}') html = self.fetch(url, **self.kwargs) for proxy in self.parse(html): logger.info(f'fetched proxy {proxy.__str__()} from {url}') ...
[ "def", "crawl", "(", "self", ")", ":", "for", "url", "in", "self", ".", "urls", ":", "logger", ".", "info", "(", "f'fetching {url}'", ")", "html", "=", "self", ".", "fetch", "(", "url", ",", "*", "*", "self", ".", "kwargs", ")", "for", "proxy", "...
[ 19, 4 ]
[ 28, 27 ]
python
en
['en', 'error', 'th']
False
device_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def device_reg(hass): """Return an empty, loaded, registry.""" return mock_device_registry(hass)
[ "def", "device_reg", "(", "hass", ")", ":", "return", "mock_device_registry", "(", "hass", ")" ]
[ 20, 0 ]
[ 22, 37 ]
python
en
['en', 'fy', 'en']
True
entity_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def entity_reg(hass): """Return an empty, loaded, registry.""" return mock_registry(hass)
[ "def", "entity_reg", "(", "hass", ")", ":", "return", "mock_registry", "(", "hass", ")" ]
[ 26, 0 ]
[ 28, 30 ]
python
en
['en', 'fy', 'en']
True
calls
(hass)
Track calls to a mock service.
Track calls to a mock service.
def calls(hass): """Track calls to a mock service.""" return async_mock_service(hass, "test", "automation")
[ "def", "calls", "(", "hass", ")", ":", "return", "async_mock_service", "(", "hass", ",", "\"test\"", ",", "\"automation\"", ")" ]
[ 32, 0 ]
[ 34, 57 ]
python
en
['en', 'en', 'en']
True
test_get_conditions
(hass, device_reg, entity_reg)
Test we get the expected conditions from a lock.
Test we get the expected conditions from a lock.
async def test_get_conditions(hass, device_reg, entity_reg): """Test we get the expected conditions from a lock.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( config_entry_id=config_entry.entry_id, ...
[ "async", "def", "test_get_conditions", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"test\"", ",", "data", "=", "{", "}", ")", "config_entry", ".", "add_to_hass", "(", "hass", ")",...
[ 37, 0 ]
[ 63, 54 ]
python
en
['en', 'en', 'en']
True
test_if_state
(hass, calls)
Test for turn_on and turn_off conditions.
Test for turn_on and turn_off conditions.
async def test_if_state(hass, calls): """Test for turn_on and turn_off conditions.""" hass.states.async_set("lock.entity", STATE_LOCKED) assert await async_setup_component( hass, automation.DOMAIN, { automation.DOMAIN: [ { "trigger": {...
[ "async", "def", "test_if_state", "(", "hass", ",", "calls", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"lock.entity\"", ",", "STATE_LOCKED", ")", "assert", "await", "async_setup_component", "(", "hass", ",", "automation", ".", "DOMAIN", ",", "...
[ 66, 0 ]
[ 125, 71 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass: HomeAssistant, config: dict)
Set up configured Dexcom.
Set up configured Dexcom.
async def async_setup(hass: HomeAssistant, config: dict): """Set up configured Dexcom.""" hass.data[DOMAIN] = {} return True
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "dict", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "}", "return", "True" ]
[ 28, 0 ]
[ 31, 15 ]
python
en
['en', 'pt', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up Dexcom from a config entry.
Set up Dexcom from a config entry.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Dexcom from a config entry.""" try: dexcom = await hass.async_add_executor_job( Dexcom, entry.data[CONF_USERNAME], entry.data[CONF_PASSWORD], entry.data[CONF_SERVER] == SERVER_...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "try", ":", "dexcom", "=", "await", "hass", ".", "async_add_executor_job", "(", "Dexcom", ",", "entry", ".", "data", "[", "CONF_USERNAME", "]"...
[ 34, 0 ]
[ 77, 15 ]
python
en
['en', 'pt', 'en']
True
async_unload_entry
(hass: HomeAssistant, entry: ConfigEntry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unload a config entry.""" unload_ok = all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload(entry, component) for component in PLATFORMS ] ) ...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "unload_ok", "=", "all", "(", "await", "asyncio", ".", "gather", "(", "*", "[", "hass", ".", "config_entries", ".", "async_forward_entry_unload...
[ 80, 0 ]
[ 94, 20 ]
python
en
['en', 'es', 'en']
True
update_listener
(hass, entry)
Handle options update.
Handle options update.
async def update_listener(hass, entry): """Handle options update.""" await hass.config_entries.async_reload(entry.entry_id)
[ "async", "def", "update_listener", "(", "hass", ",", "entry", ")", ":", "await", "hass", ".", "config_entries", ".", "async_reload", "(", "entry", ".", "entry_id", ")" ]
[ 97, 0 ]
[ 99, 58 ]
python
en
['en', 'nl', 'en']
True
TFAttention.causal_attention_mask
(nd, ns, dtype)
1's in the lower triangle, counting from the lower right corner. Same as tf.matrix_band_part(tf.ones([nd, ns]), -1, ns-nd), but doesn't produce garbage on TPUs.
1's in the lower triangle, counting from the lower right corner. Same as tf.matrix_band_part(tf.ones([nd, ns]), -1, ns-nd), but doesn't produce garbage on TPUs.
def causal_attention_mask(nd, ns, dtype): """ 1's in the lower triangle, counting from the lower right corner. Same as tf.matrix_band_part(tf.ones([nd, ns]), -1, ns-nd), but doesn't produce garbage on TPUs. """ i = tf.range(nd)[:, None] j = tf.range(ns) m = i >= j...
[ "def", "causal_attention_mask", "(", "nd", ",", "ns", ",", "dtype", ")", ":", "i", "=", "tf", ".", "range", "(", "nd", ")", "[", ":", ",", "None", "]", "j", "=", "tf", ".", "range", "(", "ns", ")", "m", "=", "i", ">=", "j", "-", "ns", "+", ...
[ 90, 4 ]
[ 98, 32 ]
python
en
['en', 'error', 'th']
False
config
(*args, **kwargs)
r""" # Using torch.hub ! import torch config = torch.hub.load('huggingface/transformers', 'config', 'bert-base-uncased') # Download configuration from huggingface.co and cache. config = torch.hub.load('huggingface/transformers', 'config', './test/bert_sa...
r""" # Using torch.hub ! import torch
def config(*args, **kwargs): r""" # Using torch.hub ! import torch config = torch.hub.load('huggingface/transformers', 'config', 'bert-base-uncased') # Download configuration from huggingface.co and cache. config = torch.hub.load('huggingface/transfo...
[ "def", "config", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "AutoConfig", ".", "from_pretrained", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 36, 0 ]
[ 52, 54 ]
python
cy
['en', 'cy', 'hi']
False
tokenizer
(*args, **kwargs)
r""" # Using torch.hub ! import torch tokenizer = torch.hub.load('huggingface/transformers', 'tokenizer', 'bert-base-uncased') # Download vocabulary from huggingface.co and cache. tokenizer = torch.hub.load('huggingface/transformers', 'tokenizer', './test/bert_saved_model/') # E.g. ...
r""" # Using torch.hub ! import torch
def tokenizer(*args, **kwargs): r""" # Using torch.hub ! import torch tokenizer = torch.hub.load('huggingface/transformers', 'tokenizer', 'bert-base-uncased') # Download vocabulary from huggingface.co and cache. tokenizer = torch.hub.load('huggingface/transformers', 'tokenizer', ...
[ "def", "tokenizer", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "AutoTokenizer", ".", "from_pretrained", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 56, 0 ]
[ 66, 57 ]
python
cy
['en', 'cy', 'hi']
False
model
(*args, **kwargs)
r""" # Using torch.hub ! import torch model = torch.hub.load('huggingface/transformers', 'model', 'bert-base-uncased') # Download model and configuration from huggingface.co and cache. model = torch.hub.load('huggingface/transformers', 'model', './test/bert_model/') ...
r""" # Using torch.hub ! import torch
def model(*args, **kwargs): r""" # Using torch.hub ! import torch model = torch.hub.load('huggingface/transformers', 'model', 'bert-base-uncased') # Download model and configuration from huggingface.co and cache. model = torch.hub.load('huggingface/transformers', ...
[ "def", "model", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "AutoModel", ".", "from_pretrained", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 70, 0 ]
[ 85, 53 ]
python
cy
['en', 'cy', 'hi']
False
modelWithLMHead
(*args, **kwargs)
r""" # Using torch.hub ! import torch model = torch.hub.load('huggingface/transformers', 'modelWithLMHead', 'bert-base-uncased') # Download model and configuration from huggingface.co and cache. model = torch.hub.load('huggingface/transformers', 'modelWithLMHead', './test/bert_model/...
r""" # Using torch.hub ! import torch
def modelWithLMHead(*args, **kwargs): r""" # Using torch.hub ! import torch model = torch.hub.load('huggingface/transformers', 'modelWithLMHead', 'bert-base-uncased') # Download model and configuration from huggingface.co and cache. model = torch.hub.load('huggingface/transformer...
[ "def", "modelWithLMHead", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "AutoModelWithLMHead", ".", "from_pretrained", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 89, 0 ]
[ 103, 63 ]
python
cy
['en', 'cy', 'hi']
False
modelForSequenceClassification
(*args, **kwargs)
r""" # Using torch.hub ! import torch model = torch.hub.load('huggingface/transformers', 'modelForSequenceClassification', 'bert-base-uncased') # Download model and configuration from huggingface.co and cache. model = torch.hub.load('huggingface/transformers', 'modelF...
r""" # Using torch.hub ! import torch
def modelForSequenceClassification(*args, **kwargs): r""" # Using torch.hub ! import torch model = torch.hub.load('huggingface/transformers', 'modelForSequenceClassification', 'bert-base-uncased') # Download model and configuration from huggingface.co and cache. m...
[ "def", "modelForSequenceClassification", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "AutoModelForSequenceClassification", ".", "from_pretrained", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 107, 0 ]
[ 122, 78 ]
python
cy
['en', 'cy', 'hi']
False
modelForQuestionAnswering
(*args, **kwargs)
r""" # Using torch.hub ! import torch model = torch.hub.load('huggingface/transformers', 'modelForQuestionAnswering', 'bert-base-uncased') # Download model and configuration from huggingface.co and cache. model = torch.hub.load('huggingface/transformers', 'modelForQuestionAnswering',...
r""" # Using torch.hub ! import torch
def modelForQuestionAnswering(*args, **kwargs): r""" # Using torch.hub ! import torch model = torch.hub.load('huggingface/transformers', 'modelForQuestionAnswering', 'bert-base-uncased') # Download model and configuration from huggingface.co and cache. model = torch.hub.load('hug...
[ "def", "modelForQuestionAnswering", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "AutoModelForQuestionAnswering", ".", "from_pretrained", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 126, 0 ]
[ 140, 73 ]
python
cy
['en', 'cy', 'hi']
False
PickledCorpusReader.__init__
(self, root, fileids=PKL_PATTERN, **kwargs)
Initialize the corpus reader. Categorization arguments (``cat_pattern``, ``cat_map``, and ``cat_file``) are passed to the ``CategorizedCorpusReader`` constructor. The remaining arguments are passed to the ``CorpusReader`` constructor.
Initialize the corpus reader. Categorization arguments (``cat_pattern``, ``cat_map``, and ``cat_file``) are passed to the ``CategorizedCorpusReader`` constructor. The remaining arguments are passed to the ``CorpusReader`` constructor.
def __init__(self, root, fileids=PKL_PATTERN, **kwargs): """ Initialize the corpus reader. Categorization arguments (``cat_pattern``, ``cat_map``, and ``cat_file``) are passed to the ``CategorizedCorpusReader`` constructor. The remaining arguments are passed to the ``CorpusRead...
[ "def", "__init__", "(", "self", ",", "root", ",", "fileids", "=", "PKL_PATTERN", ",", "*", "*", "kwargs", ")", ":", "# Add the default category pattern if not passed into the class.", "if", "not", "any", "(", "key", ".", "startswith", "(", "'cat_'", ")", "for", ...
[ 15, 4 ]
[ 27, 50 ]
python
en
['en', 'error', 'th']
False
PickledCorpusReader._resolve
(self, fileids, categories)
Returns a list of fileids or categories depending on what is passed to each internal corpus reader function. This primarily bubbles up to the high level ``docs`` method, but is implemented here similar to the nltk ``CategorizedPlaintextCorpusReader``.
Returns a list of fileids or categories depending on what is passed to each internal corpus reader function. This primarily bubbles up to the high level ``docs`` method, but is implemented here similar to the nltk ``CategorizedPlaintextCorpusReader``.
def _resolve(self, fileids, categories): """ Returns a list of fileids or categories depending on what is passed to each internal corpus reader function. This primarily bubbles up to the high level ``docs`` method, but is implemented here similar to the nltk ``CategorizedPlaintex...
[ "def", "_resolve", "(", "self", ",", "fileids", ",", "categories", ")", ":", "if", "fileids", "is", "not", "None", "and", "categories", "is", "not", "None", ":", "raise", "ValueError", "(", "\"Specify fileids or categories, not both\"", ")", "if", "categories", ...
[ 29, 4 ]
[ 41, 22 ]
python
en
['en', 'error', 'th']
False
PickledCorpusReader.docs
(self, fileids=None, categories=None)
Returns the document loaded from a pickled object for every file in the corpus. Similar to the BaleenCorpusReader, this uses a generator to acheive memory safe iteration.
Returns the document loaded from a pickled object for every file in the corpus. Similar to the BaleenCorpusReader, this uses a generator to acheive memory safe iteration.
def docs(self, fileids=None, categories=None): """ Returns the document loaded from a pickled object for every file in the corpus. Similar to the BaleenCorpusReader, this uses a generator to acheive memory safe iteration. """ # Resolve the fileids and the categories ...
[ "def", "docs", "(", "self", ",", "fileids", "=", "None", ",", "categories", "=", "None", ")", ":", "# Resolve the fileids and the categories", "fileids", "=", "self", ".", "_resolve", "(", "fileids", ",", "categories", ")", "# Create a generator, loading one documen...
[ 43, 4 ]
[ 55, 36 ]
python
en
['en', 'error', 'th']
False
PickledCorpusReader.paras
(self, fileids=None, categories=None)
Returns a generator of paragraphs where each paragraph is a list of sentences, which is in turn a list of (token, tag) tuples.
Returns a generator of paragraphs where each paragraph is a list of sentences, which is in turn a list of (token, tag) tuples.
def paras(self, fileids=None, categories=None): """ Returns a generator of paragraphs where each paragraph is a list of sentences, which is in turn a list of (token, tag) tuples. """ for doc in self.docs(fileids, categories): for paragraph in doc: yiel...
[ "def", "paras", "(", "self", ",", "fileids", "=", "None", ",", "categories", "=", "None", ")", ":", "for", "doc", "in", "self", ".", "docs", "(", "fileids", ",", "categories", ")", ":", "for", "paragraph", "in", "doc", ":", "yield", "paragraph" ]
[ 57, 4 ]
[ 64, 31 ]
python
en
['en', 'error', 'th']
False
PickledCorpusReader.sents
(self, fileids=None, categories=None)
Returns a generator of sentences where each sentence is a list of (token, tag) tuples.
Returns a generator of sentences where each sentence is a list of (token, tag) tuples.
def sents(self, fileids=None, categories=None): """ Returns a generator of sentences where each sentence is a list of (token, tag) tuples. """ for paragraph in self.paras(fileids, categories): for sentence in paragraph: yield sentence
[ "def", "sents", "(", "self", ",", "fileids", "=", "None", ",", "categories", "=", "None", ")", ":", "for", "paragraph", "in", "self", ".", "paras", "(", "fileids", ",", "categories", ")", ":", "for", "sentence", "in", "paragraph", ":", "yield", "senten...
[ 66, 4 ]
[ 73, 30 ]
python
en
['en', 'error', 'th']
False
PickledCorpusReader.words
(self, fileids=None, categories=None)
Returns a generator of (token, tag) tuples.
Returns a generator of (token, tag) tuples.
def words(self, fileids=None, categories=None): """ Returns a generator of (token, tag) tuples. """ for token in self.tagged(fileids, categories): yield token[0]
[ "def", "words", "(", "self", ",", "fileids", "=", "None", ",", "categories", "=", "None", ")", ":", "for", "token", "in", "self", ".", "tagged", "(", "fileids", ",", "categories", ")", ":", "yield", "token", "[", "0", "]" ]
[ 80, 4 ]
[ 85, 26 ]
python
en
['en', 'error', 'th']
False
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the mysensors climate.
Set up the mysensors climate.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the mysensors climate.""" mysensors.setup_mysensors_platform( hass, DOMAIN, discovery_info, MySensorsHVAC, async_add_entities=async_add_entities, )
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "mysensors", ".", "setup_mysensors_platform", "(", "hass", ",", "DOMAIN", ",", "discovery_info", ",", "MySensorsHVAC", ",",...
[ 34, 0 ]
[ 42, 5 ]
python
en
['en', 'en', 'en']
True
MySensorsHVAC.supported_features
(self)
Return the list of supported features.
Return the list of supported features.
def supported_features(self): """Return the list of supported features.""" features = 0 set_req = self.gateway.const.SetReq if set_req.V_HVAC_SPEED in self._values: features = features | SUPPORT_FAN_MODE if ( set_req.V_HVAC_SETPOINT_COOL in self._values ...
[ "def", "supported_features", "(", "self", ")", ":", "features", "=", "0", "set_req", "=", "self", ".", "gateway", ".", "const", ".", "SetReq", "if", "set_req", ".", "V_HVAC_SPEED", "in", "self", ".", "_values", ":", "features", "=", "features", "|", "SUP...
[ 49, 4 ]
[ 62, 23 ]
python
en
['en', 'en', 'en']
True
MySensorsHVAC.assumed_state
(self)
Return True if unable to access real state of entity.
Return True if unable to access real state of entity.
def assumed_state(self): """Return True if unable to access real state of entity.""" return self.gateway.optimistic
[ "def", "assumed_state", "(", "self", ")", ":", "return", "self", ".", "gateway", ".", "optimistic" ]
[ 65, 4 ]
[ 67, 38 ]
python
en
['en', 'en', 'en']
True
MySensorsHVAC.temperature_unit
(self)
Return the unit of measurement.
Return the unit of measurement.
def temperature_unit(self): """Return the unit of measurement.""" return TEMP_CELSIUS if self.gateway.metric else TEMP_FAHRENHEIT
[ "def", "temperature_unit", "(", "self", ")", ":", "return", "TEMP_CELSIUS", "if", "self", ".", "gateway", ".", "metric", "else", "TEMP_FAHRENHEIT" ]
[ 70, 4 ]
[ 72, 71 ]
python
en
['en', 'la', 'en']
True
MySensorsHVAC.current_temperature
(self)
Return the current temperature.
Return the current temperature.
def current_temperature(self): """Return the current temperature.""" value = self._values.get(self.gateway.const.SetReq.V_TEMP) if value is not None: value = float(value) return value
[ "def", "current_temperature", "(", "self", ")", ":", "value", "=", "self", ".", "_values", ".", "get", "(", "self", ".", "gateway", ".", "const", ".", "SetReq", ".", "V_TEMP", ")", "if", "value", "is", "not", "None", ":", "value", "=", "float", "(", ...
[ 75, 4 ]
[ 82, 20 ]
python
en
['en', 'la', 'en']
True
MySensorsHVAC.target_temperature
(self)
Return the temperature we try to reach.
Return the temperature we try to reach.
def target_temperature(self): """Return the temperature we try to reach.""" set_req = self.gateway.const.SetReq if ( set_req.V_HVAC_SETPOINT_COOL in self._values and set_req.V_HVAC_SETPOINT_HEAT in self._values ): return None temp = self._value...
[ "def", "target_temperature", "(", "self", ")", ":", "set_req", "=", "self", ".", "gateway", ".", "const", ".", "SetReq", "if", "(", "set_req", ".", "V_HVAC_SETPOINT_COOL", "in", "self", ".", "_values", "and", "set_req", ".", "V_HVAC_SETPOINT_HEAT", "in", "se...
[ 85, 4 ]
[ 96, 56 ]
python
en
['en', 'en', 'en']
True
MySensorsHVAC.target_temperature_high
(self)
Return the highbound target temperature we try to reach.
Return the highbound target temperature we try to reach.
def target_temperature_high(self): """Return the highbound target temperature we try to reach.""" set_req = self.gateway.const.SetReq if set_req.V_HVAC_SETPOINT_HEAT in self._values: temp = self._values.get(set_req.V_HVAC_SETPOINT_COOL) return float(temp) if temp is not N...
[ "def", "target_temperature_high", "(", "self", ")", ":", "set_req", "=", "self", ".", "gateway", ".", "const", ".", "SetReq", "if", "set_req", ".", "V_HVAC_SETPOINT_HEAT", "in", "self", ".", "_values", ":", "temp", "=", "self", ".", "_values", ".", "get", ...
[ 99, 4 ]
[ 104, 60 ]
python
en
['en', 'en', 'en']
True
MySensorsHVAC.target_temperature_low
(self)
Return the lowbound target temperature we try to reach.
Return the lowbound target temperature we try to reach.
def target_temperature_low(self): """Return the lowbound target temperature we try to reach.""" set_req = self.gateway.const.SetReq if set_req.V_HVAC_SETPOINT_COOL in self._values: temp = self._values.get(set_req.V_HVAC_SETPOINT_HEAT) return float(temp) if temp is not Non...
[ "def", "target_temperature_low", "(", "self", ")", ":", "set_req", "=", "self", ".", "gateway", ".", "const", ".", "SetReq", "if", "set_req", ".", "V_HVAC_SETPOINT_COOL", "in", "self", ".", "_values", ":", "temp", "=", "self", ".", "_values", ".", "get", ...
[ 107, 4 ]
[ 112, 60 ]
python
en
['en', 'en', 'en']
True
MySensorsHVAC.hvac_mode
(self)
Return current operation ie. heat, cool, idle.
Return current operation ie. heat, cool, idle.
def hvac_mode(self): """Return current operation ie. heat, cool, idle.""" return self._values.get(self.value_type)
[ "def", "hvac_mode", "(", "self", ")", ":", "return", "self", ".", "_values", ".", "get", "(", "self", ".", "value_type", ")" ]
[ 115, 4 ]
[ 117, 48 ]
python
en
['nl', 'en', 'en']
True
MySensorsHVAC.hvac_modes
(self)
List of available operation modes.
List of available operation modes.
def hvac_modes(self): """List of available operation modes.""" return OPERATION_LIST
[ "def", "hvac_modes", "(", "self", ")", ":", "return", "OPERATION_LIST" ]
[ 120, 4 ]
[ 122, 29 ]
python
en
['en', 'en', 'en']
True
MySensorsHVAC.fan_mode
(self)
Return the fan setting.
Return the fan setting.
def fan_mode(self): """Return the fan setting.""" return self._values.get(self.gateway.const.SetReq.V_HVAC_SPEED)
[ "def", "fan_mode", "(", "self", ")", ":", "return", "self", ".", "_values", ".", "get", "(", "self", ".", "gateway", ".", "const", ".", "SetReq", ".", "V_HVAC_SPEED", ")" ]
[ 125, 4 ]
[ 127, 71 ]
python
en
['en', 'fy', 'en']
True
MySensorsHVAC.fan_modes
(self)
List of available fan modes.
List of available fan modes.
def fan_modes(self): """List of available fan modes.""" return FAN_LIST
[ "def", "fan_modes", "(", "self", ")", ":", "return", "FAN_LIST" ]
[ 130, 4 ]
[ 132, 23 ]
python
en
['en', 'en', 'en']
True
MySensorsHVAC.async_set_temperature
(self, **kwargs)
Set new target temperature.
Set new target temperature.
async def async_set_temperature(self, **kwargs): """Set new target temperature.""" set_req = self.gateway.const.SetReq temp = kwargs.get(ATTR_TEMPERATURE) low = kwargs.get(ATTR_TARGET_TEMP_LOW) high = kwargs.get(ATTR_TARGET_TEMP_HIGH) heat = self._values.get(set_req.V_HVA...
[ "async", "def", "async_set_temperature", "(", "self", ",", "*", "*", "kwargs", ")", ":", "set_req", "=", "self", ".", "gateway", ".", "const", ".", "SetReq", "temp", "=", "kwargs", ".", "get", "(", "ATTR_TEMPERATURE", ")", "low", "=", "kwargs", ".", "g...
[ 134, 4 ]
[ 164, 43 ]
python
en
['en', 'ca', 'en']
True
MySensorsHVAC.async_set_fan_mode
(self, fan_mode)
Set new target temperature.
Set new target temperature.
async def async_set_fan_mode(self, fan_mode): """Set new target temperature.""" set_req = self.gateway.const.SetReq self.gateway.set_child_value( self.node_id, self.child_id, set_req.V_HVAC_SPEED, fan_mode, ack=1 ) if self.gateway.optimistic: # Optimistica...
[ "async", "def", "async_set_fan_mode", "(", "self", ",", "fan_mode", ")", ":", "set_req", "=", "self", ".", "gateway", ".", "const", ".", "SetReq", "self", ".", "gateway", ".", "set_child_value", "(", "self", ".", "node_id", ",", "self", ".", "child_id", ...
[ 166, 4 ]
[ 175, 39 ]
python
en
['en', 'ca', 'en']
True
MySensorsHVAC.async_set_hvac_mode
(self, hvac_mode)
Set new target temperature.
Set new target temperature.
async def async_set_hvac_mode(self, hvac_mode): """Set new target temperature.""" self.gateway.set_child_value( self.node_id, self.child_id, self.value_type, DICT_HA_TO_MYS[hvac_mode], ack=1, ) if self.gateway.optimistic: ...
[ "async", "def", "async_set_hvac_mode", "(", "self", ",", "hvac_mode", ")", ":", "self", ".", "gateway", ".", "set_child_value", "(", "self", ".", "node_id", ",", "self", ".", "child_id", ",", "self", ".", "value_type", ",", "DICT_HA_TO_MYS", "[", "hvac_mode"...
[ 177, 4 ]
[ 189, 39 ]
python
en
['en', 'ca', 'en']
True
MySensorsHVAC.async_update
(self)
Update the controller with the latest value from a sensor.
Update the controller with the latest value from a sensor.
async def async_update(self): """Update the controller with the latest value from a sensor.""" await super().async_update() self._values[self.value_type] = DICT_MYS_TO_HA[self._values[self.value_type]]
[ "async", "def", "async_update", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_update", "(", ")", "self", ".", "_values", "[", "self", ".", "value_type", "]", "=", "DICT_MYS_TO_HA", "[", "self", ".", "_values", "[", "self", ".", "value_...
[ 191, 4 ]
[ 194, 85 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Initialize of The Things Network component.
Initialize of The Things Network component.
async def async_setup(hass, config): """Initialize of The Things Network component.""" conf = config[DOMAIN] app_id = conf.get(CONF_APP_ID) access_key = conf.get(CONF_ACCESS_KEY) hass.data[DATA_TTN] = {TTN_ACCESS_KEY: access_key, TTN_APP_ID: app_id} return True
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "conf", "=", "config", "[", "DOMAIN", "]", "app_id", "=", "conf", ".", "get", "(", "CONF_APP_ID", ")", "access_key", "=", "conf", ".", "get", "(", "CONF_ACCESS_KEY", ")", "hass", ".",...
[ 31, 0 ]
[ 39, 15 ]
python
en
['en', 'en', 'en']
True
load_tf_weights_in_convbert
(model, config, tf_checkpoint_path)
Load tf checkpoints in a pytorch model.
Load tf checkpoints in a pytorch model.
def load_tf_weights_in_convbert(model, config, tf_checkpoint_path): """Load tf checkpoints in a pytorch model.""" try: import tensorflow as tf except ImportError: logger.error( "Loading a TensorFlow model in PyTorch, requires TensorFlow to be installed. Please see " "...
[ "def", "load_tf_weights_in_convbert", "(", "model", ",", "config", ",", "tf_checkpoint_path", ")", ":", "try", ":", "import", "tensorflow", "as", "tf", "except", "ImportError", ":", "logger", ".", "error", "(", "\"Loading a TensorFlow model in PyTorch, requires TensorFl...
[ 61, 0 ]
[ 182, 16 ]
python
en
['en', 'en', 'en']
True
ConvBertPreTrainedModel._init_weights
(self, module)
Initialize the weights
Initialize the weights
def _init_weights(self, module): """ Initialize the weights """ if isinstance(module, nn.Linear): # Slightly different from the TF version which uses truncated_normal for initialization # cf https://github.com/pytorch/pytorch/pull/5617 module.weight.data.normal_(mean=...
[ "def", "_init_weights", "(", "self", ",", "module", ")", ":", "if", "isinstance", "(", "module", ",", "nn", ".", "Linear", ")", ":", "# Slightly different from the TF version which uses truncated_normal for initialization", "# cf https://github.com/pytorch/pytorch/pull/5617", ...
[ 239, 4 ]
[ 253, 41 ]
python
en
['en', 'en', 'en']
True
get_scanner
(hass, config)
Validate the configuration and return a DD-WRT scanner.
Validate the configuration and return a DD-WRT scanner.
def get_scanner(hass, config): """Validate the configuration and return a DD-WRT scanner.""" try: return DdWrtDeviceScanner(config[DOMAIN]) except ConnectionError: return None
[ "def", "get_scanner", "(", "hass", ",", "config", ")", ":", "try", ":", "return", "DdWrtDeviceScanner", "(", "config", "[", "DOMAIN", "]", ")", "except", "ConnectionError", ":", "return", "None" ]
[ 45, 0 ]
[ 50, 19 ]
python
en
['en', 'en', 'en']
True
_parse_ddwrt_response
(data_str)
Parse the DD-WRT data format.
Parse the DD-WRT data format.
def _parse_ddwrt_response(data_str): """Parse the DD-WRT data format.""" return dict(_DDWRT_DATA_REGEX.findall(data_str))
[ "def", "_parse_ddwrt_response", "(", "data_str", ")", ":", "return", "dict", "(", "_DDWRT_DATA_REGEX", ".", "findall", "(", "data_str", ")", ")" ]
[ 167, 0 ]
[ 169, 52 ]
python
en
['en', 'en', 'en']
True
DdWrtDeviceScanner.__init__
(self, config)
Initialize the DD-WRT scanner.
Initialize the DD-WRT scanner.
def __init__(self, config): """Initialize the DD-WRT scanner.""" self.protocol = "https" if config[CONF_SSL] else "http" self.verify_ssl = config[CONF_VERIFY_SSL] self.host = config[CONF_HOST] self.username = config[CONF_USERNAME] self.password = config[CONF_PASSWORD] ...
[ "def", "__init__", "(", "self", ",", "config", ")", ":", "self", ".", "protocol", "=", "\"https\"", "if", "config", "[", "CONF_SSL", "]", "else", "\"http\"", "self", ".", "verify_ssl", "=", "config", "[", "CONF_VERIFY_SSL", "]", "self", ".", "host", "=",...
[ 56, 4 ]
[ 72, 68 ]
python
en
['en', 'en', 'en']
True
DdWrtDeviceScanner.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.""" self._update_info() return self.last_results
[ "def", "scan_devices", "(", "self", ")", ":", "self", ".", "_update_info", "(", ")", "return", "self", ".", "last_results" ]
[ 74, 4 ]
[ 78, 32 ]
python
en
['en', 'en', 'en']
True
DdWrtDeviceScanner.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.""" # If not initialised and not already scanned and not found. if device not in self.mac2name: url = f"{self.protocol}://{self.host}/Status_Lan.live.asp" data = self.get_dd...
[ "def", "get_device_name", "(", "self", ",", "device", ")", ":", "# If not initialised and not already scanned and not found.", "if", "device", "not", "in", "self", ".", "mac2name", ":", "url", "=", "f\"{self.protocol}://{self.host}/Status_Lan.live.asp\"", "data", "=", "se...
[ 80, 4 ]
[ 109, 40 ]
python
en
['en', 'en', 'en']
True
DdWrtDeviceScanner._update_info
(self)
Ensure the information from the DD-WRT router is up to date. Return boolean if scanning successful.
Ensure the information from the DD-WRT router is up to date.
def _update_info(self): """Ensure the information from the DD-WRT router is up to date. Return boolean if scanning successful. """ _LOGGER.debug("Checking ARP") endpoint = "Wireless" if self.wireless_only else "Lan" url = f"{self.protocol}://{self.host}/Status_{endpoint...
[ "def", "_update_info", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Checking ARP\"", ")", "endpoint", "=", "\"Wireless\"", "if", "self", ".", "wireless_only", "else", "\"Lan\"", "url", "=", "f\"{self.protocol}://{self.host}/Status_{endpoint}.live.asp\"", "d...
[ 111, 4 ]
[ 142, 19 ]
python
en
['en', 'en', 'en']
True
DdWrtDeviceScanner.get_ddwrt_data
(self, url)
Retrieve data from DD-WRT and return parsed result.
Retrieve data from DD-WRT and return parsed result.
def get_ddwrt_data(self, url): """Retrieve data from DD-WRT and return parsed result.""" try: response = requests.get( url, auth=(self.username, self.password), timeout=4, verify=self.verify_ssl, ) except req...
[ "def", "get_ddwrt_data", "(", "self", ",", "url", ")", ":", "try", ":", "response", "=", "requests", ".", "get", "(", "url", ",", "auth", "=", "(", "self", ".", "username", ",", "self", ".", "password", ")", ",", "timeout", "=", "4", ",", "verify",...
[ 144, 4 ]
[ 164, 67 ]
python
en
['en', 'en', 'en']
True
test_attributes
(hass)
Test weather attributes.
Test weather attributes.
async def test_attributes(hass): """Test weather attributes.""" assert await async_setup_component( hass, weather.DOMAIN, {"weather": {"platform": "demo"}} ) hass.config.units = METRIC_SYSTEM await hass.async_block_till_done() state = hass.states.get("weather.demo_weather_south") as...
[ "async", "def", "test_attributes", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "weather", ".", "DOMAIN", ",", "{", "\"weather\"", ":", "{", "\"platform\"", ":", "\"demo\"", "}", "}", ")", "hass", ".", "config", ".",...
[ 21, 0 ]
[ 54, 44 ]
python
en
['en', 'en', 'en']
True
test_temperature_convert
(hass)
Test temperature conversion.
Test temperature conversion.
async def test_temperature_convert(hass): """Test temperature conversion.""" assert await async_setup_component( hass, weather.DOMAIN, {"weather": {"platform": "demo"}} ) hass.config.units = METRIC_SYSTEM await hass.async_block_till_done() state = hass.states.get("weather.demo_weather_n...
[ "async", "def", "test_temperature_convert", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "weather", ".", "DOMAIN", ",", "{", "\"weather\"", ":", "{", "\"platform\"", ":", "\"demo\"", "}", "}", ")", "hass", ".", "config...
[ 57, 0 ]
[ 71, 52 ]
python
en
['en', 'la', 'en']
True
async_setup_entry
(hass: HomeAssistantType, config_entry: ConfigEntry)
Set up Huawei LTE component from config entry.
Set up Huawei LTE component from config entry.
async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry) -> bool: """Set up Huawei LTE component from config entry.""" url = config_entry.data[CONF_URL] # Override settings from YAML config, but only if they're changed in it # Old values are stored as *_from_yaml in the config en...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "config_entry", ":", "ConfigEntry", ")", "->", "bool", ":", "url", "=", "config_entry", ".", "data", "[", "CONF_URL", "]", "# Override settings from YAML config, but only if they're changed...
[ 301, 0 ]
[ 450, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
( hass: HomeAssistantType, config_entry: ConfigEntry )
Unload config entry.
Unload config entry.
async def async_unload_entry( hass: HomeAssistantType, config_entry: ConfigEntry ) -> bool: """Unload config entry.""" # Forward config entry unload to platforms for domain in CONFIG_ENTRY_PLATFORMS: await hass.config_entries.async_forward_entry_unload(config_entry, domain) # Forget about ...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistantType", ",", "config_entry", ":", "ConfigEntry", ")", "->", "bool", ":", "# Forward config entry unload to platforms", "for", "domain", "in", "CONFIG_ENTRY_PLATFORMS", ":", "await", "hass", ".", "con...
[ 453, 0 ]
[ 466, 15 ]
python
da
['da', 'es', 'en']
False
async_setup
(hass: HomeAssistantType, config: ConfigType)
Set up Huawei LTE component.
Set up Huawei LTE component.
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: """Set up Huawei LTE component.""" # dicttoxml (used by huawei-lte-api) has uselessly verbose INFO level. # https://github.com/quandyfactory/dicttoxml/issues/60 logging.getLogger("dicttoxml").setLevel(logging.WARNING) # Ar...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistantType", ",", "config", ":", "ConfigType", ")", "->", "bool", ":", "# dicttoxml (used by huawei-lte-api) has uselessly verbose INFO level.", "# https://github.com/quandyfactory/dicttoxml/issues/60", "logging", ".", "g...
[ 469, 0 ]
[ 549, 15 ]
python
en
['en', 'en', 'en']
True
async_signal_options_update
( hass: HomeAssistantType, config_entry: ConfigEntry )
Handle config entry options update.
Handle config entry options update.
async def async_signal_options_update( hass: HomeAssistantType, config_entry: ConfigEntry ) -> None: """Handle config entry options update.""" async_dispatcher_send(hass, UPDATE_OPTIONS_SIGNAL, config_entry)
[ "async", "def", "async_signal_options_update", "(", "hass", ":", "HomeAssistantType", ",", "config_entry", ":", "ConfigEntry", ")", "->", "None", ":", "async_dispatcher_send", "(", "hass", ",", "UPDATE_OPTIONS_SIGNAL", ",", "config_entry", ")" ]
[ 552, 0 ]
[ 556, 68 ]
python
en
['en', 'en', 'en']
True
async_migrate_entry
( hass: HomeAssistantType, config_entry: ConfigEntry )
Migrate config entry to new version.
Migrate config entry to new version.
async def async_migrate_entry( hass: HomeAssistantType, config_entry: ConfigEntry ) -> bool: """Migrate config entry to new version.""" if config_entry.version == 1: options = dict(config_entry.options) recipient = options.get(CONF_RECIPIENT) if isinstance(recipient, str): ...
[ "async", "def", "async_migrate_entry", "(", "hass", ":", "HomeAssistantType", ",", "config_entry", ":", "ConfigEntry", ")", "->", "bool", ":", "if", "config_entry", ".", "version", "==", "1", ":", "options", "=", "dict", "(", "config_entry", ".", "options", ...
[ 559, 0 ]
[ 571, 15 ]
python
en
['en', 'en', 'en']
True
SimpliSafeFlowHandler.__init__
(self)
Initialize the config flow.
Initialize the config flow.
def __init__(self): """Initialize the config flow.""" self.full_data_schema = vol.Schema( { vol.Required(CONF_USERNAME): str, vol.Required(CONF_PASSWORD): str, vol.Optional(CONF_CODE): str, } ) self.password_data_sch...
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "full_data_schema", "=", "vol", ".", "Schema", "(", "{", "vol", ".", "Required", "(", "CONF_USERNAME", ")", ":", "str", ",", "vol", ".", "Required", "(", "CONF_PASSWORD", ")", ":", "str", ",", "v...
[ 24, 4 ]
[ 37, 29 ]
python
en
['en', 'en', 'en']
True