body stringlengths 26 98.2k | body_hash int64 -9,222,864,604,528,158,000 9,221,803,474B | docstring stringlengths 1 16.8k | path stringlengths 5 230 | name stringlengths 1 96 | repository_name stringlengths 7 89 | lang stringclasses 1
value | body_without_docstring stringlengths 20 98.2k |
|---|---|---|---|---|---|---|---|
@property
def device_state_attributes(self) -> (Mapping[(str, Any)] | None):
'Return entity specific state attributes.\n\n This method is deprecated, platform classes should implement\n extra_state_attributes instead.\n '
return None | -1,323,270,001,650,424,000 | Return entity specific state attributes.
This method is deprecated, platform classes should implement
extra_state_attributes instead. | homeassistant/helpers/entity.py | device_state_attributes | algra4/core | python | @property
def device_state_attributes(self) -> (Mapping[(str, Any)] | None):
'Return entity specific state attributes.\n\n This method is deprecated, platform classes should implement\n extra_state_attributes instead.\n '
return None |
@property
def extra_state_attributes(self) -> (Mapping[(str, Any)] | None):
'Return entity specific state attributes.\n\n Implemented by platform classes. Convention for attribute names\n is lowercase snake_case.\n '
if hasattr(self, '_attr_extra_state_attributes'):
return self._att... | 7,074,571,657,564,478,000 | Return entity specific state attributes.
Implemented by platform classes. Convention for attribute names
is lowercase snake_case. | homeassistant/helpers/entity.py | extra_state_attributes | algra4/core | python | @property
def extra_state_attributes(self) -> (Mapping[(str, Any)] | None):
'Return entity specific state attributes.\n\n Implemented by platform classes. Convention for attribute names\n is lowercase snake_case.\n '
if hasattr(self, '_attr_extra_state_attributes'):
return self._att... |
@property
def device_info(self) -> (DeviceInfo | None):
'Return device specific attributes.\n\n Implemented by platform classes.\n '
return self._attr_device_info | -131,480,113,962,214,270 | Return device specific attributes.
Implemented by platform classes. | homeassistant/helpers/entity.py | device_info | algra4/core | python | @property
def device_info(self) -> (DeviceInfo | None):
'Return device specific attributes.\n\n Implemented by platform classes.\n '
return self._attr_device_info |
@property
def device_class(self) -> (str | None):
'Return the class of this device, from component DEVICE_CLASSES.'
if hasattr(self, '_attr_device_class'):
return self._attr_device_class
if hasattr(self, 'entity_description'):
return self.entity_description.device_class
return None | -5,219,341,481,153,056,000 | Return the class of this device, from component DEVICE_CLASSES. | homeassistant/helpers/entity.py | device_class | algra4/core | python | @property
def device_class(self) -> (str | None):
if hasattr(self, '_attr_device_class'):
return self._attr_device_class
if hasattr(self, 'entity_description'):
return self.entity_description.device_class
return None |
@property
def unit_of_measurement(self) -> (str | None):
'Return the unit of measurement of this entity, if any.'
if hasattr(self, '_attr_unit_of_measurement'):
return self._attr_unit_of_measurement
if hasattr(self, 'entity_description'):
return self.entity_description.unit_of_measurement
... | -3,540,950,534,694,055,000 | Return the unit of measurement of this entity, if any. | homeassistant/helpers/entity.py | unit_of_measurement | algra4/core | python | @property
def unit_of_measurement(self) -> (str | None):
if hasattr(self, '_attr_unit_of_measurement'):
return self._attr_unit_of_measurement
if hasattr(self, 'entity_description'):
return self.entity_description.unit_of_measurement
return None |
@property
def icon(self) -> (str | None):
'Return the icon to use in the frontend, if any.'
if hasattr(self, '_attr_icon'):
return self._attr_icon
if hasattr(self, 'entity_description'):
return self.entity_description.icon
return None | -3,294,291,017,478,937,600 | Return the icon to use in the frontend, if any. | homeassistant/helpers/entity.py | icon | algra4/core | python | @property
def icon(self) -> (str | None):
if hasattr(self, '_attr_icon'):
return self._attr_icon
if hasattr(self, 'entity_description'):
return self.entity_description.icon
return None |
@property
def entity_picture(self) -> (str | None):
'Return the entity picture to use in the frontend, if any.'
return self._attr_entity_picture | -7,043,696,854,560,105,000 | Return the entity picture to use in the frontend, if any. | homeassistant/helpers/entity.py | entity_picture | algra4/core | python | @property
def entity_picture(self) -> (str | None):
return self._attr_entity_picture |
@property
def available(self) -> bool:
'Return True if entity is available.'
return self._attr_available | -1,685,129,627,032,272,600 | Return True if entity is available. | homeassistant/helpers/entity.py | available | algra4/core | python | @property
def available(self) -> bool:
return self._attr_available |
@property
def assumed_state(self) -> bool:
'Return True if unable to access real state of the entity.'
return self._attr_assumed_state | 7,459,250,895,532,809,000 | Return True if unable to access real state of the entity. | homeassistant/helpers/entity.py | assumed_state | algra4/core | python | @property
def assumed_state(self) -> bool:
return self._attr_assumed_state |
@property
def force_update(self) -> bool:
'Return True if state updates should be forced.\n\n If True, a state change will be triggered anytime the state property is\n updated, not just when the value changes.\n '
if hasattr(self, '_attr_force_update'):
return self._attr_force_updat... | 5,255,442,537,079,365,000 | Return True if state updates should be forced.
If True, a state change will be triggered anytime the state property is
updated, not just when the value changes. | homeassistant/helpers/entity.py | force_update | algra4/core | python | @property
def force_update(self) -> bool:
'Return True if state updates should be forced.\n\n If True, a state change will be triggered anytime the state property is\n updated, not just when the value changes.\n '
if hasattr(self, '_attr_force_update'):
return self._attr_force_updat... |
@property
def supported_features(self) -> (int | None):
'Flag supported features.'
return self._attr_supported_features | 5,283,299,116,938,334,000 | Flag supported features. | homeassistant/helpers/entity.py | supported_features | algra4/core | python | @property
def supported_features(self) -> (int | None):
return self._attr_supported_features |
@property
def context_recent_time(self) -> timedelta:
'Time that a context is considered recent.'
return self._attr_context_recent_time | -5,792,920,726,120,755,000 | Time that a context is considered recent. | homeassistant/helpers/entity.py | context_recent_time | algra4/core | python | @property
def context_recent_time(self) -> timedelta:
return self._attr_context_recent_time |
@property
def entity_registry_enabled_default(self) -> bool:
'Return if the entity should be enabled when first added to the entity registry.'
if hasattr(self, '_attr_entity_registry_enabled_default'):
return self._attr_entity_registry_enabled_default
if hasattr(self, 'entity_description'):
... | 7,500,122,496,969,868,000 | Return if the entity should be enabled when first added to the entity registry. | homeassistant/helpers/entity.py | entity_registry_enabled_default | algra4/core | python | @property
def entity_registry_enabled_default(self) -> bool:
if hasattr(self, '_attr_entity_registry_enabled_default'):
return self._attr_entity_registry_enabled_default
if hasattr(self, 'entity_description'):
return self.entity_description.entity_registry_enabled_default
return True |
@property
def entity_registry_visible_default(self) -> bool:
'Return if the entity should be visible when first added to the entity registry.'
if hasattr(self, '_attr_entity_registry_visible_default'):
return self._attr_entity_registry_visible_default
if hasattr(self, 'entity_description'):
... | 557,998,721,559,602,300 | Return if the entity should be visible when first added to the entity registry. | homeassistant/helpers/entity.py | entity_registry_visible_default | algra4/core | python | @property
def entity_registry_visible_default(self) -> bool:
if hasattr(self, '_attr_entity_registry_visible_default'):
return self._attr_entity_registry_visible_default
if hasattr(self, 'entity_description'):
return self.entity_description.entity_registry_visible_default
return True |
@property
def attribution(self) -> (str | None):
'Return the attribution.'
return self._attr_attribution | 6,895,732,983,763,131,000 | Return the attribution. | homeassistant/helpers/entity.py | attribution | algra4/core | python | @property
def attribution(self) -> (str | None):
return self._attr_attribution |
@property
def entity_category(self) -> (EntityCategory | None):
'Return the category of the entity, if any.'
if hasattr(self, '_attr_entity_category'):
return self._attr_entity_category
if hasattr(self, 'entity_description'):
return self.entity_description.entity_category
return None | -5,674,864,290,690,756,000 | Return the category of the entity, if any. | homeassistant/helpers/entity.py | entity_category | algra4/core | python | @property
def entity_category(self) -> (EntityCategory | None):
if hasattr(self, '_attr_entity_category'):
return self._attr_entity_category
if hasattr(self, 'entity_description'):
return self.entity_description.entity_category
return None |
@property
def enabled(self) -> bool:
'Return if the entity is enabled in the entity registry.\n\n If an entity is not part of the registry, it cannot be disabled\n and will therefore always be enabled.\n '
return ((self.registry_entry is None) or (not self.registry_entry.disabled)) | -4,212,866,319,016,292,000 | Return if the entity is enabled in the entity registry.
If an entity is not part of the registry, it cannot be disabled
and will therefore always be enabled. | homeassistant/helpers/entity.py | enabled | algra4/core | python | @property
def enabled(self) -> bool:
'Return if the entity is enabled in the entity registry.\n\n If an entity is not part of the registry, it cannot be disabled\n and will therefore always be enabled.\n '
return ((self.registry_entry is None) or (not self.registry_entry.disabled)) |
@callback
def async_set_context(self, context: Context) -> None:
'Set the context the entity currently operates under.'
self._context = context
self._context_set = dt_util.utcnow() | 7,498,294,261,140,403,000 | Set the context the entity currently operates under. | homeassistant/helpers/entity.py | async_set_context | algra4/core | python | @callback
def async_set_context(self, context: Context) -> None:
self._context = context
self._context_set = dt_util.utcnow() |
async def async_update_ha_state(self, force_refresh: bool=False) -> None:
'Update Home Assistant with current state of entity.\n\n If force_refresh == True will update entity before setting state.\n\n This method must be run in the event loop.\n '
if (self.hass is None):
raise Runti... | -2,629,200,371,007,674,000 | Update Home Assistant with current state of entity.
If force_refresh == True will update entity before setting state.
This method must be run in the event loop. | homeassistant/helpers/entity.py | async_update_ha_state | algra4/core | python | async def async_update_ha_state(self, force_refresh: bool=False) -> None:
'Update Home Assistant with current state of entity.\n\n If force_refresh == True will update entity before setting state.\n\n This method must be run in the event loop.\n '
if (self.hass is None):
raise Runti... |
@callback
def async_write_ha_state(self) -> None:
'Write the state to the state machine.'
if (self.hass is None):
raise RuntimeError(f'Attribute hass is None for {self}')
if (self.entity_id is None):
raise NoEntitySpecifiedError(f'No entity id specified for entity {self.name}')
self._asy... | -7,814,871,863,252,089,000 | Write the state to the state machine. | homeassistant/helpers/entity.py | async_write_ha_state | algra4/core | python | @callback
def async_write_ha_state(self) -> None:
if (self.hass is None):
raise RuntimeError(f'Attribute hass is None for {self}')
if (self.entity_id is None):
raise NoEntitySpecifiedError(f'No entity id specified for entity {self.name}')
self._async_write_ha_state() |
def _stringify_state(self, available: bool) -> str:
'Convert state to string.'
if (not available):
return STATE_UNAVAILABLE
if ((state := self.state) is None):
return STATE_UNKNOWN
if isinstance(state, float):
return f'{state:.{FLOAT_PRECISION}}'
return str(state) | -8,878,403,925,894,521,000 | Convert state to string. | homeassistant/helpers/entity.py | _stringify_state | algra4/core | python | def _stringify_state(self, available: bool) -> str:
if (not available):
return STATE_UNAVAILABLE
if ((state := self.state) is None):
return STATE_UNKNOWN
if isinstance(state, float):
return f'{state:.{FLOAT_PRECISION}}'
return str(state) |
@callback
def _async_write_ha_state(self) -> None:
'Write the state to the state machine.'
if (self._platform_state == EntityPlatformState.REMOVED):
return
if (self.registry_entry and self.registry_entry.disabled_by):
if (not self._disabled_reported):
self._disabled_reported = Tr... | -6,635,918,349,019,637,000 | Write the state to the state machine. | homeassistant/helpers/entity.py | _async_write_ha_state | algra4/core | python | @callback
def _async_write_ha_state(self) -> None:
if (self._platform_state == EntityPlatformState.REMOVED):
return
if (self.registry_entry and self.registry_entry.disabled_by):
if (not self._disabled_reported):
self._disabled_reported = True
assert (self.platform is... |
def schedule_update_ha_state(self, force_refresh: bool=False) -> None:
'Schedule an update ha state change task.\n\n Scheduling the update avoids executor deadlocks.\n\n Entity state and attributes are read when the update ha state change\n task is executed.\n If state is changed more th... | 4,930,532,841,608,269,000 | Schedule an update ha state change task.
Scheduling the update avoids executor deadlocks.
Entity state and attributes are read when the update ha state change
task is executed.
If state is changed more than once before the ha state change task has
been executed, the intermediate state transitions will be missed. | homeassistant/helpers/entity.py | schedule_update_ha_state | algra4/core | python | def schedule_update_ha_state(self, force_refresh: bool=False) -> None:
'Schedule an update ha state change task.\n\n Scheduling the update avoids executor deadlocks.\n\n Entity state and attributes are read when the update ha state change\n task is executed.\n If state is changed more th... |
@callback
def async_schedule_update_ha_state(self, force_refresh: bool=False) -> None:
'Schedule an update ha state change task.\n\n This method must be run in the event loop.\n Scheduling the update avoids executor deadlocks.\n\n Entity state and attributes are read when the update ha state ch... | 221,238,759,961,931,260 | Schedule an update ha state change task.
This method must be run in the event loop.
Scheduling the update avoids executor deadlocks.
Entity state and attributes are read when the update ha state change
task is executed.
If state is changed more than once before the ha state change task has
been executed, the intermed... | homeassistant/helpers/entity.py | async_schedule_update_ha_state | algra4/core | python | @callback
def async_schedule_update_ha_state(self, force_refresh: bool=False) -> None:
'Schedule an update ha state change task.\n\n This method must be run in the event loop.\n Scheduling the update avoids executor deadlocks.\n\n Entity state and attributes are read when the update ha state ch... |
async def async_device_update(self, warning: bool=True) -> None:
"Process 'update' or 'async_update' from entity.\n\n This method is a coroutine.\n "
if self._update_staged:
return
self._update_staged = True
if self.parallel_updates:
(await self.parallel_updates.acquire())
... | -9,035,073,522,249,991,000 | Process 'update' or 'async_update' from entity.
This method is a coroutine. | homeassistant/helpers/entity.py | async_device_update | algra4/core | python | async def async_device_update(self, warning: bool=True) -> None:
"Process 'update' or 'async_update' from entity.\n\n This method is a coroutine.\n "
if self._update_staged:
return
self._update_staged = True
if self.parallel_updates:
(await self.parallel_updates.acquire())
... |
@callback
def async_on_remove(self, func: CALLBACK_TYPE) -> None:
'Add a function to call when entity is removed or not added.'
if (self._on_remove is None):
self._on_remove = []
self._on_remove.append(func) | 3,669,661,432,994,837,000 | Add a function to call when entity is removed or not added. | homeassistant/helpers/entity.py | async_on_remove | algra4/core | python | @callback
def async_on_remove(self, func: CALLBACK_TYPE) -> None:
if (self._on_remove is None):
self._on_remove = []
self._on_remove.append(func) |
async def async_removed_from_registry(self) -> None:
'Run when entity has been removed from entity registry.\n\n To be extended by integrations.\n ' | -4,028,870,512,133,826,600 | Run when entity has been removed from entity registry.
To be extended by integrations. | homeassistant/helpers/entity.py | async_removed_from_registry | algra4/core | python | async def async_removed_from_registry(self) -> None:
'Run when entity has been removed from entity registry.\n\n To be extended by integrations.\n ' |
@callback
def add_to_platform_start(self, hass: HomeAssistant, platform: EntityPlatform, parallel_updates: (asyncio.Semaphore | None)) -> None:
'Start adding an entity to a platform.'
if (self._platform_state == EntityPlatformState.ADDED):
raise HomeAssistantError(f'Entity {self.entity_id} cannot be add... | -8,311,372,291,523,876,000 | Start adding an entity to a platform. | homeassistant/helpers/entity.py | add_to_platform_start | algra4/core | python | @callback
def add_to_platform_start(self, hass: HomeAssistant, platform: EntityPlatform, parallel_updates: (asyncio.Semaphore | None)) -> None:
if (self._platform_state == EntityPlatformState.ADDED):
raise HomeAssistantError(f'Entity {self.entity_id} cannot be added a second time to an entity platform'... |
def _call_on_remove_callbacks(self) -> None:
'Call callbacks registered by async_on_remove.'
if (self._on_remove is None):
return
while self._on_remove:
self._on_remove.pop()() | -4,055,272,837,616,563,700 | Call callbacks registered by async_on_remove. | homeassistant/helpers/entity.py | _call_on_remove_callbacks | algra4/core | python | def _call_on_remove_callbacks(self) -> None:
if (self._on_remove is None):
return
while self._on_remove:
self._on_remove.pop()() |
@callback
def add_to_platform_abort(self) -> None:
'Abort adding an entity to a platform.'
self._platform_state = EntityPlatformState.NOT_ADDED
self._call_on_remove_callbacks()
self.hass = None
self.platform = None
self.parallel_updates = None | -4,424,440,936,371,736,600 | Abort adding an entity to a platform. | homeassistant/helpers/entity.py | add_to_platform_abort | algra4/core | python | @callback
def add_to_platform_abort(self) -> None:
self._platform_state = EntityPlatformState.NOT_ADDED
self._call_on_remove_callbacks()
self.hass = None
self.platform = None
self.parallel_updates = None |
async def add_to_platform_finish(self) -> None:
'Finish adding an entity to a platform.'
(await self.async_internal_added_to_hass())
(await self.async_added_to_hass())
self.async_write_ha_state() | -2,320,288,375,294,386,000 | Finish adding an entity to a platform. | homeassistant/helpers/entity.py | add_to_platform_finish | algra4/core | python | async def add_to_platform_finish(self) -> None:
(await self.async_internal_added_to_hass())
(await self.async_added_to_hass())
self.async_write_ha_state() |
async def async_remove(self, *, force_remove: bool=False) -> None:
"Remove entity from Home Assistant.\n\n If the entity has a non disabled entry in the entity registry,\n the entity's state will be set to unavailable, in the same way\n as when the entity registry is loaded.\n\n If the e... | 8,390,034,581,321,268,000 | Remove entity from Home Assistant.
If the entity has a non disabled entry in the entity registry,
the entity's state will be set to unavailable, in the same way
as when the entity registry is loaded.
If the entity doesn't have a non disabled entry in the entity registry,
or if force_remove=True, its state will be rem... | homeassistant/helpers/entity.py | async_remove | algra4/core | python | async def async_remove(self, *, force_remove: bool=False) -> None:
"Remove entity from Home Assistant.\n\n If the entity has a non disabled entry in the entity registry,\n the entity's state will be set to unavailable, in the same way\n as when the entity registry is loaded.\n\n If the e... |
async def async_added_to_hass(self) -> None:
'Run when entity about to be added to hass.\n\n To be extended by integrations.\n ' | -5,585,018,881,033,491,000 | Run when entity about to be added to hass.
To be extended by integrations. | homeassistant/helpers/entity.py | async_added_to_hass | algra4/core | python | async def async_added_to_hass(self) -> None:
'Run when entity about to be added to hass.\n\n To be extended by integrations.\n ' |
async def async_will_remove_from_hass(self) -> None:
'Run when entity will be removed from hass.\n\n To be extended by integrations.\n ' | -8,817,618,303,532,068,000 | Run when entity will be removed from hass.
To be extended by integrations. | homeassistant/helpers/entity.py | async_will_remove_from_hass | algra4/core | python | async def async_will_remove_from_hass(self) -> None:
'Run when entity will be removed from hass.\n\n To be extended by integrations.\n ' |
@callback
def async_registry_entry_updated(self) -> None:
'Run when the entity registry entry has been updated.\n\n To be extended by integrations.\n ' | -3,633,366,077,162,349,600 | Run when the entity registry entry has been updated.
To be extended by integrations. | homeassistant/helpers/entity.py | async_registry_entry_updated | algra4/core | python | @callback
def async_registry_entry_updated(self) -> None:
'Run when the entity registry entry has been updated.\n\n To be extended by integrations.\n ' |
async def async_internal_added_to_hass(self) -> None:
'Run when entity about to be added to hass.\n\n Not to be extended by integrations.\n '
if self.platform:
info = {'domain': self.platform.platform_name, 'custom_component': ('custom_components' in type(self).__module__)}
if self... | 1,359,335,844,177,028,900 | Run when entity about to be added to hass.
Not to be extended by integrations. | homeassistant/helpers/entity.py | async_internal_added_to_hass | algra4/core | python | async def async_internal_added_to_hass(self) -> None:
'Run when entity about to be added to hass.\n\n Not to be extended by integrations.\n '
if self.platform:
info = {'domain': self.platform.platform_name, 'custom_component': ('custom_components' in type(self).__module__)}
if self... |
async def async_internal_will_remove_from_hass(self) -> None:
'Run when entity will be removed from hass.\n\n Not to be extended by integrations.\n '
if self.platform:
self.hass.data[DATA_ENTITY_SOURCE].pop(self.entity_id) | 1,536,591,258,824,101,000 | Run when entity will be removed from hass.
Not to be extended by integrations. | homeassistant/helpers/entity.py | async_internal_will_remove_from_hass | algra4/core | python | async def async_internal_will_remove_from_hass(self) -> None:
'Run when entity will be removed from hass.\n\n Not to be extended by integrations.\n '
if self.platform:
self.hass.data[DATA_ENTITY_SOURCE].pop(self.entity_id) |
async def _async_registry_updated(self, event: Event) -> None:
'Handle entity registry update.'
data = event.data
if (data['action'] == 'remove'):
(await self.async_removed_from_registry())
self.registry_entry = None
(await self.async_remove())
if (data['action'] != 'update'):
... | -5,765,629,528,305,339,000 | Handle entity registry update. | homeassistant/helpers/entity.py | _async_registry_updated | algra4/core | python | async def _async_registry_updated(self, event: Event) -> None:
data = event.data
if (data['action'] == 'remove'):
(await self.async_removed_from_registry())
self.registry_entry = None
(await self.async_remove())
if (data['action'] != 'update'):
return
ent_reg = er.as... |
def __eq__(self, other: Any) -> bool:
'Return the comparison.'
if (not isinstance(other, self.__class__)):
return False
if ((self.unique_id is None) or (other.unique_id is None)):
return False
if ((self.platform is not None) or (other.platform is not None)):
if ((self.platform is... | -4,800,598,507,128,546,000 | Return the comparison. | homeassistant/helpers/entity.py | __eq__ | algra4/core | python | def __eq__(self, other: Any) -> bool:
if (not isinstance(other, self.__class__)):
return False
if ((self.unique_id is None) or (other.unique_id is None)):
return False
if ((self.platform is not None) or (other.platform is not None)):
if ((self.platform is None) or (other.platfor... |
def __repr__(self) -> str:
'Return the representation.'
return f'<Entity {self.name}: {self.state}>' | 5,428,986,823,689,221,000 | Return the representation. | homeassistant/helpers/entity.py | __repr__ | algra4/core | python | def __repr__(self) -> str:
return f'<Entity {self.name}: {self.state}>' |
async def async_request_call(self, coro: Awaitable) -> None:
'Process request batched.'
if self.parallel_updates:
(await self.parallel_updates.acquire())
try:
(await coro)
finally:
if self.parallel_updates:
self.parallel_updates.release() | 3,011,644,997,447,190,500 | Process request batched. | homeassistant/helpers/entity.py | async_request_call | algra4/core | python | async def async_request_call(self, coro: Awaitable) -> None:
if self.parallel_updates:
(await self.parallel_updates.acquire())
try:
(await coro)
finally:
if self.parallel_updates:
self.parallel_updates.release() |
def _suggest_report_issue(self) -> str:
'Suggest to report an issue.'
report_issue = ''
if ('custom_components' in type(self).__module__):
report_issue = 'report it to the custom component author.'
else:
report_issue = 'create a bug report at https://github.com/home-assistant/core/issues... | 6,459,600,896,278,370,000 | Suggest to report an issue. | homeassistant/helpers/entity.py | _suggest_report_issue | algra4/core | python | def _suggest_report_issue(self) -> str:
report_issue =
if ('custom_components' in type(self).__module__):
report_issue = 'report it to the custom component author.'
else:
report_issue = 'create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue'
... |
@property
@final
def state(self) -> (Literal[('on', 'off')] | None):
'Return the state.'
if ((is_on := self.is_on) is None):
return None
return (STATE_ON if is_on else STATE_OFF) | 1,586,572,218,295,235,300 | Return the state. | homeassistant/helpers/entity.py | state | algra4/core | python | @property
@final
def state(self) -> (Literal[('on', 'off')] | None):
if ((is_on := self.is_on) is None):
return None
return (STATE_ON if is_on else STATE_OFF) |
@property
def is_on(self) -> (bool | None):
'Return True if entity is on.'
return self._attr_is_on | -7,774,850,306,356,158,000 | Return True if entity is on. | homeassistant/helpers/entity.py | is_on | algra4/core | python | @property
def is_on(self) -> (bool | None):
return self._attr_is_on |
def turn_on(self, **kwargs: Any) -> None:
'Turn the entity on.'
raise NotImplementedError() | 2,322,256,188,001,028,600 | Turn the entity on. | homeassistant/helpers/entity.py | turn_on | algra4/core | python | def turn_on(self, **kwargs: Any) -> None:
raise NotImplementedError() |
async def async_turn_on(self, **kwargs: Any) -> None:
'Turn the entity on.'
(await self.hass.async_add_executor_job(ft.partial(self.turn_on, **kwargs))) | -8,243,134,644,201,260,000 | Turn the entity on. | homeassistant/helpers/entity.py | async_turn_on | algra4/core | python | async def async_turn_on(self, **kwargs: Any) -> None:
(await self.hass.async_add_executor_job(ft.partial(self.turn_on, **kwargs))) |
def turn_off(self, **kwargs: Any) -> None:
'Turn the entity off.'
raise NotImplementedError() | -3,799,708,282,002,590,700 | Turn the entity off. | homeassistant/helpers/entity.py | turn_off | algra4/core | python | def turn_off(self, **kwargs: Any) -> None:
raise NotImplementedError() |
async def async_turn_off(self, **kwargs: Any) -> None:
'Turn the entity off.'
(await self.hass.async_add_executor_job(ft.partial(self.turn_off, **kwargs))) | -6,121,593,494,274,528,000 | Turn the entity off. | homeassistant/helpers/entity.py | async_turn_off | algra4/core | python | async def async_turn_off(self, **kwargs: Any) -> None:
(await self.hass.async_add_executor_job(ft.partial(self.turn_off, **kwargs))) |
def toggle(self, **kwargs: Any) -> None:
'Toggle the entity.'
if self.is_on:
self.turn_off(**kwargs)
else:
self.turn_on(**kwargs) | -6,398,084,867,639,560,000 | Toggle the entity. | homeassistant/helpers/entity.py | toggle | algra4/core | python | def toggle(self, **kwargs: Any) -> None:
if self.is_on:
self.turn_off(**kwargs)
else:
self.turn_on(**kwargs) |
async def async_toggle(self, **kwargs: Any) -> None:
'Toggle the entity.'
if self.is_on:
(await self.async_turn_off(**kwargs))
else:
(await self.async_turn_on(**kwargs)) | 6,141,564,757,956,466,000 | Toggle the entity. | homeassistant/helpers/entity.py | async_toggle | algra4/core | python | async def async_toggle(self, **kwargs: Any) -> None:
if self.is_on:
(await self.async_turn_off(**kwargs))
else:
(await self.async_turn_on(**kwargs)) |
def _get_prefix_list_direction_out_prefix_name(self):
'\n Getter method for prefix_list_direction_out_prefix_name, mapped from YANG variable /routing_system/router/router_bgp/address_family/ipv4/ipv4_unicast/default_vrf/neighbor/af_ipv4_neighbor_peergroup_holder/af_ipv4_neighbor_peergroup/prefix_list/direction_o... | -3,966,028,733,959,844,000 | Getter method for prefix_list_direction_out_prefix_name, mapped from YANG variable /routing_system/router/router_bgp/address_family/ipv4/ipv4_unicast/default_vrf/neighbor/af_ipv4_neighbor_peergroup_holder/af_ipv4_neighbor_peergroup/prefix_list/direction_out/prefix_list_direction_out_prefix_name (nei-prefix-list-filter) | pybind/slxos/v17s_1_02/routing_system/router/router_bgp/address_family/ipv4/ipv4_unicast/default_vrf/neighbor/af_ipv4_neighbor_peergroup_holder/af_ipv4_neighbor_peergroup/prefix_list/direction_out/__init__.py | _get_prefix_list_direction_out_prefix_name | extremenetworks/pybind | python | def _get_prefix_list_direction_out_prefix_name(self):
'\n \n '
return self.__prefix_list_direction_out_prefix_name |
def _set_prefix_list_direction_out_prefix_name(self, v, load=False):
'\n Setter method for prefix_list_direction_out_prefix_name, mapped from YANG variable /routing_system/router/router_bgp/address_family/ipv4/ipv4_unicast/default_vrf/neighbor/af_ipv4_neighbor_peergroup_holder/af_ipv4_neighbor_peergroup/prefix_l... | 7,387,998,423,933,128,000 | Setter method for prefix_list_direction_out_prefix_name, mapped from YANG variable /routing_system/router/router_bgp/address_family/ipv4/ipv4_unicast/default_vrf/neighbor/af_ipv4_neighbor_peergroup_holder/af_ipv4_neighbor_peergroup/prefix_list/direction_out/prefix_list_direction_out_prefix_name (nei-prefix-list-filter)... | pybind/slxos/v17s_1_02/routing_system/router/router_bgp/address_family/ipv4/ipv4_unicast/default_vrf/neighbor/af_ipv4_neighbor_peergroup_holder/af_ipv4_neighbor_peergroup/prefix_list/direction_out/__init__.py | _set_prefix_list_direction_out_prefix_name | extremenetworks/pybind | python | def _set_prefix_list_direction_out_prefix_name(self, v, load=False):
'\n Setter method for prefix_list_direction_out_prefix_name, mapped from YANG variable /routing_system/router/router_bgp/address_family/ipv4/ipv4_unicast/default_vrf/neighbor/af_ipv4_neighbor_peergroup_holder/af_ipv4_neighbor_peergroup/prefix_l... |
def _get_prefix_list_direction_out(self):
'\n Getter method for prefix_list_direction_out, mapped from YANG variable /routing_system/router/router_bgp/address_family/ipv4/ipv4_unicast/default_vrf/neighbor/af_ipv4_neighbor_peergroup_holder/af_ipv4_neighbor_peergroup/prefix_list/direction_out/prefix_list_direction... | -8,154,108,608,796,012,000 | Getter method for prefix_list_direction_out, mapped from YANG variable /routing_system/router/router_bgp/address_family/ipv4/ipv4_unicast/default_vrf/neighbor/af_ipv4_neighbor_peergroup_holder/af_ipv4_neighbor_peergroup/prefix_list/direction_out/prefix_list_direction_out (empty) | pybind/slxos/v17s_1_02/routing_system/router/router_bgp/address_family/ipv4/ipv4_unicast/default_vrf/neighbor/af_ipv4_neighbor_peergroup_holder/af_ipv4_neighbor_peergroup/prefix_list/direction_out/__init__.py | _get_prefix_list_direction_out | extremenetworks/pybind | python | def _get_prefix_list_direction_out(self):
'\n \n '
return self.__prefix_list_direction_out |
def _set_prefix_list_direction_out(self, v, load=False):
'\n Setter method for prefix_list_direction_out, mapped from YANG variable /routing_system/router/router_bgp/address_family/ipv4/ipv4_unicast/default_vrf/neighbor/af_ipv4_neighbor_peergroup_holder/af_ipv4_neighbor_peergroup/prefix_list/direction_out/prefix... | 8,742,975,862,918,580,000 | Setter method for prefix_list_direction_out, mapped from YANG variable /routing_system/router/router_bgp/address_family/ipv4/ipv4_unicast/default_vrf/neighbor/af_ipv4_neighbor_peergroup_holder/af_ipv4_neighbor_peergroup/prefix_list/direction_out/prefix_list_direction_out (empty)
If this variable is read-only (config: f... | pybind/slxos/v17s_1_02/routing_system/router/router_bgp/address_family/ipv4/ipv4_unicast/default_vrf/neighbor/af_ipv4_neighbor_peergroup_holder/af_ipv4_neighbor_peergroup/prefix_list/direction_out/__init__.py | _set_prefix_list_direction_out | extremenetworks/pybind | python | def _set_prefix_list_direction_out(self, v, load=False):
'\n Setter method for prefix_list_direction_out, mapped from YANG variable /routing_system/router/router_bgp/address_family/ipv4/ipv4_unicast/default_vrf/neighbor/af_ipv4_neighbor_peergroup_holder/af_ipv4_neighbor_peergroup/prefix_list/direction_out/prefix... |
def test_new_user(new_user):
'\n GIVEN a User model\n WHEN a new User is created\n THEN check the username and birthday fields are defined correctly\n '
assert (new_user.name == 'test')
assert (new_user.birthday == date(day=1, month=12, year=1989)) | -3,446,939,272,959,490,000 | GIVEN a User model
WHEN a new User is created
THEN check the username and birthday fields are defined correctly | tests/unit/test_app.py | test_new_user | atsikham/flask-test-app | python | def test_new_user(new_user):
'\n GIVEN a User model\n WHEN a new User is created\n THEN check the username and birthday fields are defined correctly\n '
assert (new_user.name == 'test')
assert (new_user.birthday == date(day=1, month=12, year=1989)) |
def __init__(self, length, dec_rep):
'\n Constructor\n\n Parameters\n ----------\n length : int\n dec_rep : int\n\n Returns\n -------\n\n '
self.len = length
self.dec_rep = dec_rep
self.max_len = 16
assert (length <= self.max_len), 'bit vector ... | 4,263,336,906,014,317,600 | Constructor
Parameters
----------
length : int
dec_rep : int
Returns
------- | qubiter/BitVector.py | __init__ | yourball/qubiter | python | def __init__(self, length, dec_rep):
'\n Constructor\n\n Parameters\n ----------\n length : int\n dec_rep : int\n\n Returns\n -------\n\n '
self.len = length
self.dec_rep = dec_rep
self.max_len = 16
assert (length <= self.max_len), 'bit vector ... |
@staticmethod
def copy(bvec):
'\n Copy constructor, returns a new BitVector which is a copy of the\n BitVector bvec.\n\n Parameters\n ----------\n bvec : BitVector\n\n Returns\n -------\n BitVector\n\n '
return BitVector(bvec.len, bvec.dec_rep) | -3,857,372,566,116,804,600 | Copy constructor, returns a new BitVector which is a copy of the
BitVector bvec.
Parameters
----------
bvec : BitVector
Returns
-------
BitVector | qubiter/BitVector.py | copy | yourball/qubiter | python | @staticmethod
def copy(bvec):
'\n Copy constructor, returns a new BitVector which is a copy of the\n BitVector bvec.\n\n Parameters\n ----------\n bvec : BitVector\n\n Returns\n -------\n BitVector\n\n '
return BitVector(bvec.len, bvec.dec_rep) |
def bit_is_T(self, bpos):
'\n Returns True iff bit at position bpos is 1 (True)\n\n Parameters\n ----------\n bpos : int\n bit position\n\n Returns\n -------\n bool\n\n '
assert (bpos < self.len), 'bit position is too large'
mask = (1 << bpo... | -2,255,089,424,818,929,700 | Returns True iff bit at position bpos is 1 (True)
Parameters
----------
bpos : int
bit position
Returns
-------
bool | qubiter/BitVector.py | bit_is_T | yourball/qubiter | python | def bit_is_T(self, bpos):
'\n Returns True iff bit at position bpos is 1 (True)\n\n Parameters\n ----------\n bpos : int\n bit position\n\n Returns\n -------\n bool\n\n '
assert (bpos < self.len), 'bit position is too large'
mask = (1 << bpo... |
def set_bit_T(self, bpos):
'\n Sets to 1 (True) the bit of self at position bpos.\n\n Parameters\n ----------\n bpos : int\n bit position\n\n Returns\n -------\n None\n\n '
assert (bpos < self.len), 'bit position is too large'
self.dec_rep |... | 3,042,222,247,460,635,000 | Sets to 1 (True) the bit of self at position bpos.
Parameters
----------
bpos : int
bit position
Returns
-------
None | qubiter/BitVector.py | set_bit_T | yourball/qubiter | python | def set_bit_T(self, bpos):
'\n Sets to 1 (True) the bit of self at position bpos.\n\n Parameters\n ----------\n bpos : int\n bit position\n\n Returns\n -------\n None\n\n '
assert (bpos < self.len), 'bit position is too large'
self.dec_rep |... |
def set_bit_F(self, bpos):
'\n Sets to 0 (False) the bit of self at position bpos.\n\n Parameters\n ----------\n bpos : int\n bit position\n\n Returns\n -------\n None\n\n '
assert (bpos < self.len), 'bit position is too large'
self.dec_rep ... | -5,681,098,986,469,289,000 | Sets to 0 (False) the bit of self at position bpos.
Parameters
----------
bpos : int
bit position
Returns
-------
None | qubiter/BitVector.py | set_bit_F | yourball/qubiter | python | def set_bit_F(self, bpos):
'\n Sets to 0 (False) the bit of self at position bpos.\n\n Parameters\n ----------\n bpos : int\n bit position\n\n Returns\n -------\n None\n\n '
assert (bpos < self.len), 'bit position is too large'
self.dec_rep ... |
def set_all_bits_T(self):
'\n Sets to 1 (True) the bits of self at position bpos\n from 0 to len-1 inclusive.\n\n Returns\n -------\n None\n\n '
self.dec_rep = ((1 << (self.len + 1)) - 1) | 7,747,470,342,879,452,000 | Sets to 1 (True) the bits of self at position bpos
from 0 to len-1 inclusive.
Returns
-------
None | qubiter/BitVector.py | set_all_bits_T | yourball/qubiter | python | def set_all_bits_T(self):
'\n Sets to 1 (True) the bits of self at position bpos\n from 0 to len-1 inclusive.\n\n Returns\n -------\n None\n\n '
self.dec_rep = ((1 << (self.len + 1)) - 1) |
def set_all_bits_F(self):
'\n Sets to 0 (False) the bits of self at positions bpos\n from 0 to len-1 inclusive.\n\n Returns\n -------\n None\n\n '
self.dec_rep = 0 | 1,587,382,351,114,493,700 | Sets to 0 (False) the bits of self at positions bpos
from 0 to len-1 inclusive.
Returns
-------
None | qubiter/BitVector.py | set_all_bits_F | yourball/qubiter | python | def set_all_bits_F(self):
'\n Sets to 0 (False) the bits of self at positions bpos\n from 0 to len-1 inclusive.\n\n Returns\n -------\n None\n\n '
self.dec_rep = 0 |
def get_num_T_bits(self):
'\n Returns the number of 1 (True) bits at positions bpos\n from 0 to len-1 inclusive.\n\n Returns\n -------\n int\n\n '
count = 0
for bpos in range(self.len):
if self.bit_is_T(bpos):
count += 1
return count | -6,344,205,092,744,203,000 | Returns the number of 1 (True) bits at positions bpos
from 0 to len-1 inclusive.
Returns
-------
int | qubiter/BitVector.py | get_num_T_bits | yourball/qubiter | python | def get_num_T_bits(self):
'\n Returns the number of 1 (True) bits at positions bpos\n from 0 to len-1 inclusive.\n\n Returns\n -------\n int\n\n '
count = 0
for bpos in range(self.len):
if self.bit_is_T(bpos):
count += 1
return count |
def find_T_bit_to_right_of(self, bpos):
'\n Returns position of 1 (True) bit immediately to the right of\n position bpos. Returns -1 if there is no such bit.\n\n Parameters\n ----------\n bpos : int\n bit position\n\n Returns\n -------\n int\n\n ... | 6,769,676,576,450,919,000 | Returns position of 1 (True) bit immediately to the right of
position bpos. Returns -1 if there is no such bit.
Parameters
----------
bpos : int
bit position
Returns
-------
int | qubiter/BitVector.py | find_T_bit_to_right_of | yourball/qubiter | python | def find_T_bit_to_right_of(self, bpos):
'\n Returns position of 1 (True) bit immediately to the right of\n position bpos. Returns -1 if there is no such bit.\n\n Parameters\n ----------\n bpos : int\n bit position\n\n Returns\n -------\n int\n\n ... |
def find_T_bit_to_left_of(self, bpos):
'\n Returns position of 1 (True) bit immediately to the left of position\n bpos. Returns -1 if there is no such bit.\n\n Parameters\n ----------\n bpos : int\n bit position\n\n Returns\n -------\n int\n\n ... | 1,600,739,133,069,071,000 | Returns position of 1 (True) bit immediately to the left of position
bpos. Returns -1 if there is no such bit.
Parameters
----------
bpos : int
bit position
Returns
-------
int | qubiter/BitVector.py | find_T_bit_to_left_of | yourball/qubiter | python | def find_T_bit_to_left_of(self, bpos):
'\n Returns position of 1 (True) bit immediately to the left of position\n bpos. Returns -1 if there is no such bit.\n\n Parameters\n ----------\n bpos : int\n bit position\n\n Returns\n -------\n int\n\n ... |
def find_leftmost_T_bit(self):
'\n Out of all 1 (True) bits, returns position of the leftmost one of\n those to the the left of position bpos. Returns -1 if there is no\n such bit.\n\n Returns\n -------\n int\n\n '
if self.bit_is_T((self.len - 1)):
return... | -3,475,562,950,627,349,500 | Out of all 1 (True) bits, returns position of the leftmost one of
those to the the left of position bpos. Returns -1 if there is no
such bit.
Returns
-------
int | qubiter/BitVector.py | find_leftmost_T_bit | yourball/qubiter | python | def find_leftmost_T_bit(self):
'\n Out of all 1 (True) bits, returns position of the leftmost one of\n those to the the left of position bpos. Returns -1 if there is no\n such bit.\n\n Returns\n -------\n int\n\n '
if self.bit_is_T((self.len - 1)):
return... |
def find_rightmost_T_bit(self):
'\n Out of all 1 (True) bits, returns position of the rightmost one of\n those to the the right of position bpos. Returns -1 if there is no\n such bit.\n\n Returns\n -------\n int\n\n '
if self.bit_is_T(0):
return 0
els... | 2,662,890,795,470,964,700 | Out of all 1 (True) bits, returns position of the rightmost one of
those to the the right of position bpos. Returns -1 if there is no
such bit.
Returns
-------
int | qubiter/BitVector.py | find_rightmost_T_bit | yourball/qubiter | python | def find_rightmost_T_bit(self):
'\n Out of all 1 (True) bits, returns position of the rightmost one of\n those to the the right of position bpos. Returns -1 if there is no\n such bit.\n\n Returns\n -------\n int\n\n '
if self.bit_is_T(0):
return 0
els... |
def get_bit_string(self):
'\n Returns self represented as string of length self.len of ones and\n zeros. If bit_str is the output, [int(x) for x in bit_str] will turn\n result to list of ints.\n\n Returns\n -------\n str\n\n '
bit_str = ''
for beta in range((... | -3,725,536,626,985,473,500 | Returns self represented as string of length self.len of ones and
zeros. If bit_str is the output, [int(x) for x in bit_str] will turn
result to list of ints.
Returns
-------
str | qubiter/BitVector.py | get_bit_string | yourball/qubiter | python | def get_bit_string(self):
'\n Returns self represented as string of length self.len of ones and\n zeros. If bit_str is the output, [int(x) for x in bit_str] will turn\n result to list of ints.\n\n Returns\n -------\n str\n\n '
bit_str =
for beta in range((se... |
def __str__(self):
'\n Readable representation of self\n\n Returns\n -------\n str\n\n '
return ((self.get_bit_string() + '=') + str(self.dec_rep)) | -1,192,800,099,141,709,300 | Readable representation of self
Returns
-------
str | qubiter/BitVector.py | __str__ | yourball/qubiter | python | def __str__(self):
'\n Readable representation of self\n\n Returns\n -------\n str\n\n '
return ((self.get_bit_string() + '=') + str(self.dec_rep)) |
@staticmethod
def new_with_T_on_diff(bvec1, bvec2):
'\n Given two BitVectors bevc1 and bvec2, this return a BitVector which\n is a bitwise xor (mod 2 sum) of the bits of bvec1 and bvec2.\n\n Parameters\n ----------\n bvec1 : BitVector\n bvec2 : BitVector\n\n Returns\... | 7,352,476,823,073,408,000 | Given two BitVectors bevc1 and bvec2, this return a BitVector which
is a bitwise xor (mod 2 sum) of the bits of bvec1 and bvec2.
Parameters
----------
bvec1 : BitVector
bvec2 : BitVector
Returns
-------
BitVector | qubiter/BitVector.py | new_with_T_on_diff | yourball/qubiter | python | @staticmethod
def new_with_T_on_diff(bvec1, bvec2):
'\n Given two BitVectors bevc1 and bvec2, this return a BitVector which\n is a bitwise xor (mod 2 sum) of the bits of bvec1 and bvec2.\n\n Parameters\n ----------\n bvec1 : BitVector\n bvec2 : BitVector\n\n Returns\... |
@staticmethod
def get_lazy_from_normal(bit_len, normal):
'\n Throughout Qubiter, we will often refer to "Gray Code" as "lazy\n ordering". In lazy ordering with bit_len many bits, one gives a\n sequence of bit vectors of length bit_len, so that two adjacent\n items of the sequence differ ... | 7,674,673,722,284,487,000 | Throughout Qubiter, we will often refer to "Gray Code" as "lazy
ordering". In lazy ordering with bit_len many bits, one gives a
sequence of bit vectors of length bit_len, so that two adjacent
items of the sequence differ by just one bit. For example 000=0,
100=4, 110=6, 010=2, 011=3, 111=7, 101=5, 001=1. Each element o... | qubiter/BitVector.py | get_lazy_from_normal | yourball/qubiter | python | @staticmethod
def get_lazy_from_normal(bit_len, normal):
'\n Throughout Qubiter, we will often refer to "Gray Code" as "lazy\n ordering". In lazy ordering with bit_len many bits, one gives a\n sequence of bit vectors of length bit_len, so that two adjacent\n items of the sequence differ ... |
@staticmethod
def lazy_advance(old_normal, old_lazy):
'\n This method takes int "old_lazy" (which corresponds to bit vector\n "old_normal"), and changes it to the next lazy int, "new_lazy" (\n which corresponds to "new_normal").\n\n example:\n\n lazy sequence: 000, 001, 011, 010, ... | 2,850,775,961,367,675,000 | This method takes int "old_lazy" (which corresponds to bit vector
"old_normal"), and changes it to the next lazy int, "new_lazy" (
which corresponds to "new_normal").
example:
lazy sequence: 000, 001, 011, 010, 110, 111, 101, 100
old_lazy = 011
old_normal = 2 = 010
new_normal = 3 = 011
mask = (new_normal & ~old_nor... | qubiter/BitVector.py | lazy_advance | yourball/qubiter | python | @staticmethod
def lazy_advance(old_normal, old_lazy):
'\n This method takes int "old_lazy" (which corresponds to bit vector\n "old_normal"), and changes it to the next lazy int, "new_lazy" (\n which corresponds to "new_normal").\n\n example:\n\n lazy sequence: 000, 001, 011, 010, ... |
def __init__(self, sol_dim, max_iters, popsize, num_elites, cost_function, upper_bound=None, lower_bound=None, epsilon=0.001, alpha=0.25, viz_dir=None):
'Creates an instance of this class.\n Arguments:\n sol_dim (int): The dimensionality of the problem space\n max_iters (int): The maxim... | -5,363,686,924,115,796,000 | Creates an instance of this class.
Arguments:
sol_dim (int): The dimensionality of the problem space
max_iters (int): The maximum number of iterations to perform during optimization
popsize (int): The number of candidate solutions to be sampled at every iteration
num_elites (int): The number of top solu... | dr/experiment/ppo_pytorch.py | __init__ | quanvuong/domain_randomization | python | def __init__(self, sol_dim, max_iters, popsize, num_elites, cost_function, upper_bound=None, lower_bound=None, epsilon=0.001, alpha=0.25, viz_dir=None):
'Creates an instance of this class.\n Arguments:\n sol_dim (int): The dimensionality of the problem space\n max_iters (int): The maxim... |
def obtain_solution(self, init_mean, init_var):
'Optimizes the cost function using the provided initial candidate distribution\n Arguments:\n init_mean (np.ndarray): The mean of the initial candidate distribution.\n init_var (np.ndarray): The variance of the initial candidate distributi... | -1,709,952,683,294,620,700 | Optimizes the cost function using the provided initial candidate distribution
Arguments:
init_mean (np.ndarray): The mean of the initial candidate distribution.
init_var (np.ndarray): The variance of the initial candidate distribution. | dr/experiment/ppo_pytorch.py | obtain_solution | quanvuong/domain_randomization | python | def obtain_solution(self, init_mean, init_var):
'Optimizes the cost function using the provided initial candidate distribution\n Arguments:\n init_mean (np.ndarray): The mean of the initial candidate distribution.\n init_var (np.ndarray): The variance of the initial candidate distributi... |
async def async_lock(self, access_token, lock_id):
'Execute a remote lock operation.\n\n Returns a LockStatus state.\n '
return determine_lock_status((await self._async_lock(access_token, lock_id)).get('status')) | 3,962,434,966,695,672,300 | Execute a remote lock operation.
Returns a LockStatus state. | august/api_async.py | async_lock | THATDONFC/py-august | python | async def async_lock(self, access_token, lock_id):
'Execute a remote lock operation.\n\n Returns a LockStatus state.\n '
return determine_lock_status((await self._async_lock(access_token, lock_id)).get('status')) |
async def async_lock_return_activities(self, access_token, lock_id):
'Execute a remote lock operation.\n\n Returns an array of one or more august.activity.Activity objects\n\n If the lock supports door sense one of the activities\n will include the current door state.\n '
return _con... | -20,103,754,425,368,150 | Execute a remote lock operation.
Returns an array of one or more august.activity.Activity objects
If the lock supports door sense one of the activities
will include the current door state. | august/api_async.py | async_lock_return_activities | THATDONFC/py-august | python | async def async_lock_return_activities(self, access_token, lock_id):
'Execute a remote lock operation.\n\n Returns an array of one or more august.activity.Activity objects\n\n If the lock supports door sense one of the activities\n will include the current door state.\n '
return _con... |
async def async_unlock(self, access_token, lock_id):
'Execute a remote unlock operation.\n\n Returns a LockStatus state.\n '
return determine_lock_status((await self._async_unlock(access_token, lock_id)).get('status')) | 1,674,035,768,962,010,600 | Execute a remote unlock operation.
Returns a LockStatus state. | august/api_async.py | async_unlock | THATDONFC/py-august | python | async def async_unlock(self, access_token, lock_id):
'Execute a remote unlock operation.\n\n Returns a LockStatus state.\n '
return determine_lock_status((await self._async_unlock(access_token, lock_id)).get('status')) |
async def async_unlock_return_activities(self, access_token, lock_id):
'Execute a remote lock operation.\n\n Returns an array of one or more august.activity.Activity objects\n\n If the lock supports door sense one of the activities\n will include the current door state.\n '
return _c... | 2,709,392,198,846,596,600 | Execute a remote lock operation.
Returns an array of one or more august.activity.Activity objects
If the lock supports door sense one of the activities
will include the current door state. | august/api_async.py | async_unlock_return_activities | THATDONFC/py-august | python | async def async_unlock_return_activities(self, access_token, lock_id):
'Execute a remote lock operation.\n\n Returns an array of one or more august.activity.Activity objects\n\n If the lock supports door sense one of the activities\n will include the current door state.\n '
return _c... |
async def async_refresh_access_token(self, access_token):
'Obtain a new api token.'
return (await self._async_dict_to_api(self._build_refresh_access_token_request(access_token))).headers[HEADER_AUGUST_ACCESS_TOKEN] | 7,545,354,170,499,416,000 | Obtain a new api token. | august/api_async.py | async_refresh_access_token | THATDONFC/py-august | python | async def async_refresh_access_token(self, access_token):
return (await self._async_dict_to_api(self._build_refresh_access_token_request(access_token))).headers[HEADER_AUGUST_ACCESS_TOKEN] |
def __init__(self, sizes=list(), learning_rate=1.0, mini_batch_size=16, epochs=10):
'Initialize a Neural Network model.\n\n Parameters\n ----------\n sizes : list, optional\n A list of integers specifying number of neurns in each layer. Not\n required if a pretrained model... | 6,273,857,992,573,708,000 | Initialize a Neural Network model.
Parameters
----------
sizes : list, optional
A list of integers specifying number of neurns in each layer. Not
required if a pretrained model is used.
learning_rate : float, optional
Learning rate for gradient descent optimization. Defaults to 1.0
mini_batch_size : int,... | src/nn_model.py | __init__ | fredwangwang/webcam-sudoku-solver | python | def __init__(self, sizes=list(), learning_rate=1.0, mini_batch_size=16, epochs=10):
'Initialize a Neural Network model.\n\n Parameters\n ----------\n sizes : list, optional\n A list of integers specifying number of neurns in each layer. Not\n required if a pretrained model... |
def fit(self, training_data, validation_data=None):
'Fit (train) the Neural Network on provided training data. Fitting is\n carried out using Stochastic Gradient Descent Algorithm.\n\n Parameters\n ----------\n training_data : list of tuple\n A list of tuples of numpy arrays, ... | 897,726,686,871,590,900 | Fit (train) the Neural Network on provided training data. Fitting is
carried out using Stochastic Gradient Descent Algorithm.
Parameters
----------
training_data : list of tuple
A list of tuples of numpy arrays, ordered as (image, label).
validation_data : list of tuple, optional
Same as `training_data`, if p... | src/nn_model.py | fit | fredwangwang/webcam-sudoku-solver | python | def fit(self, training_data, validation_data=None):
'Fit (train) the Neural Network on provided training data. Fitting is\n carried out using Stochastic Gradient Descent Algorithm.\n\n Parameters\n ----------\n training_data : list of tuple\n A list of tuples of numpy arrays, ... |
def validate(self, validation_data):
'Validate the Neural Network on provided validation data. It uses the\n number of correctly predicted examples as validation accuracy metric.\n\n Parameters\n ----------\n validation_data : list of tuple\n\n Returns\n -------\n in... | 791,219,755,680,909,700 | Validate the Neural Network on provided validation data. It uses the
number of correctly predicted examples as validation accuracy metric.
Parameters
----------
validation_data : list of tuple
Returns
-------
int
Number of correctly predicted images. | src/nn_model.py | validate | fredwangwang/webcam-sudoku-solver | python | def validate(self, validation_data):
'Validate the Neural Network on provided validation data. It uses the\n number of correctly predicted examples as validation accuracy metric.\n\n Parameters\n ----------\n validation_data : list of tuple\n\n Returns\n -------\n in... |
def predict(self, x):
'Predict the label of a single test example (image).\n\n Parameters\n ----------\n x : numpy.array\n\n Returns\n -------\n int\n Predicted label of example (image).\n\n '
self._forward_prop(x)
return np.argmax(self._activation... | 112,982,234,359,509,470 | Predict the label of a single test example (image).
Parameters
----------
x : numpy.array
Returns
-------
int
Predicted label of example (image). | src/nn_model.py | predict | fredwangwang/webcam-sudoku-solver | python | def predict(self, x):
'Predict the label of a single test example (image).\n\n Parameters\n ----------\n x : numpy.array\n\n Returns\n -------\n int\n Predicted label of example (image).\n\n '
self._forward_prop(x)
return np.argmax(self._activation... |
def load(self, filename='model.npz'):
'Prepare a neural network from a compressed binary containing weights\n and biases arrays. Size of layers are derived from dimensions of\n numpy arrays.\n\n Parameters\n ----------\n filename : str, optional\n Name of the ``.npz`` c... | -6,871,594,500,702,750,000 | Prepare a neural network from a compressed binary containing weights
and biases arrays. Size of layers are derived from dimensions of
numpy arrays.
Parameters
----------
filename : str, optional
Name of the ``.npz`` compressed binary in models directory. | src/nn_model.py | load | fredwangwang/webcam-sudoku-solver | python | def load(self, filename='model.npz'):
'Prepare a neural network from a compressed binary containing weights\n and biases arrays. Size of layers are derived from dimensions of\n numpy arrays.\n\n Parameters\n ----------\n filename : str, optional\n Name of the ``.npz`` c... |
def save(self, filename='model.npz'):
"Save weights, biases and hyperparameters of neural network to a\n compressed binary. This ``.npz`` binary is saved in 'models' directory.\n\n Parameters\n ----------\n filename : str, optional\n Name of the ``.npz`` compressed binary in t... | 5,541,264,440,548,084,000 | Save weights, biases and hyperparameters of neural network to a
compressed binary. This ``.npz`` binary is saved in 'models' directory.
Parameters
----------
filename : str, optional
Name of the ``.npz`` compressed binary in to be saved. | src/nn_model.py | save | fredwangwang/webcam-sudoku-solver | python | def save(self, filename='model.npz'):
"Save weights, biases and hyperparameters of neural network to a\n compressed binary. This ``.npz`` binary is saved in 'models' directory.\n\n Parameters\n ----------\n filename : str, optional\n Name of the ``.npz`` compressed binary in t... |
def reset(self):
'\n\t\tReset current position to beginning.\n\t\t'
self.arm.reset()
self.current = self.arm.end_effector_position() | -1,015,991,858,288,929,900 | Reset current position to beginning. | environments/robot_arm/robot_arm.py | reset | callaunchpad/MOR | python | def reset(self):
'\n\t\t\n\t\t'
self.arm.reset()
self.current = self.arm.end_effector_position() |
def act(self, location, population, params, master):
'\n\t\tMove end effector to the given location\n\t\t'
valid = True
past = self.current
self.current = location
if (((population % self.config['record_iterations']) == 0) and master):
print('Recording')
try:
self.arm.iki... | -2,383,995,251,774,368,300 | Move end effector to the given location | environments/robot_arm/robot_arm.py | act | callaunchpad/MOR | python | def act(self, location, population, params, master):
'\n\t\t\n\t\t'
valid = True
past = self.current
self.current = location
if (((population % self.config['record_iterations']) == 0) and master):
print('Recording')
try:
self.arm.ikine(location)
timestamp = da... |
def inputs(self, t):
'\n\t\tReturn the inputs for the neural network\n\t\t'
inputs = [self.current[0], self.current[1], self.current[2], self.target[0], self.target[1], self.target[2], (t + 1)]
return inputs | -5,793,087,367,901,682,000 | Return the inputs for the neural network | environments/robot_arm/robot_arm.py | inputs | callaunchpad/MOR | python | def inputs(self, t):
'\n\t\t\n\t\t'
inputs = [self.current[0], self.current[1], self.current[2], self.target[0], self.target[1], self.target[2], (t + 1)]
return inputs |
def reward_params(self, valid):
'\n\t\tReturn the parameters for the proposed reward function\n\t\t'
params = (self.current, self.target)
return params | 692,410,265,936,325,900 | Return the parameters for the proposed reward function | environments/robot_arm/robot_arm.py | reward_params | callaunchpad/MOR | python | def reward_params(self, valid):
'\n\t\t\n\t\t'
params = (self.current, self.target)
return params |
def pre_processing(self):
'\n\t\tComplete any pending post processing tasks\n\t\t'
pass | -7,139,161,499,287,091,000 | Complete any pending post processing tasks | environments/robot_arm/robot_arm.py | pre_processing | callaunchpad/MOR | python | def pre_processing(self):
'\n\t\t\n\t\t'
pass |
def post_processing(self):
'\n\t\tComplete any pending post processing tasks\n\t\t'
pass | -1,660,335,344,934,753,500 | Complete any pending post processing tasks | environments/robot_arm/robot_arm.py | post_processing | callaunchpad/MOR | python | def post_processing(self):
'\n\t\t\n\t\t'
pass |
def cluster(df: pd.DataFrame, header_prefix: List[str]=None, maxsize: int=20, method: str='single', numeric_cat: List[str]=None, plot=False) -> List[List[str]]:
'\n Given an input dataframe, extract clusters of similar headers\n based on a set of heuristics.\n\n Args:\n df: The dataframe to cluster ... | 4,085,142,219,848,973,300 | Given an input dataframe, extract clusters of similar headers
based on a set of heuristics.
Args:
df: The dataframe to cluster headers from.
header_prefix: List of columns to remove before cluster generation.
maxsize: The max number of header clusters to generate
from the input dataframe.
metho... | src/gretel_synthetics/utils/header_clusters.py | cluster | andrewnc/gretel-synthetics | python | def cluster(df: pd.DataFrame, header_prefix: List[str]=None, maxsize: int=20, method: str='single', numeric_cat: List[str]=None, plot=False) -> List[List[str]]:
'\n Given an input dataframe, extract clusters of similar headers\n based on a set of heuristics.\n\n Args:\n df: The dataframe to cluster ... |
def __init__(self, more_items_remaining=None, total_item_count=None, continuation_token=None, items=None):
'\n Keyword args:\n more_items_remaining (bool): Returns a value of `true` if subsequent items can be retrieved.\n total_item_count (int): The total number of records after applyin... | -7,882,988,585,856,706,000 | Keyword args:
more_items_remaining (bool): Returns a value of `true` if subsequent items can be retrieved.
total_item_count (int): The total number of records after applying all filter query parameters. The `total_item_count` will be calculated if and only if the corresponding query parameter `total_item_count`... | pypureclient/flasharray/FA_2_5/models/policy_rule_smb_client_get_response.py | __init__ | Flav-STOR-WL/py-pure-client | python | def __init__(self, more_items_remaining=None, total_item_count=None, continuation_token=None, items=None):
'\n Keyword args:\n more_items_remaining (bool): Returns a value of `true` if subsequent items can be retrieved.\n total_item_count (int): The total number of records after applyin... |
def to_dict(self):
'Returns the model properties as a dict'
result = {}
for (attr, _) in six.iteritems(self.swagger_types):
if hasattr(self, attr):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map((lambda x: (x.to_dict() if hasat... | 8,830,407,163,213,029,000 | Returns the model properties as a dict | pypureclient/flasharray/FA_2_5/models/policy_rule_smb_client_get_response.py | to_dict | Flav-STOR-WL/py-pure-client | python | def to_dict(self):
result = {}
for (attr, _) in six.iteritems(self.swagger_types):
if hasattr(self, attr):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map((lambda x: (x.to_dict() if hasattr(x, 'to_dict') else x)), value))
... |
def to_str(self):
'Returns the string representation of the model'
return pprint.pformat(self.to_dict()) | 5,849,158,643,760,736,000 | Returns the string representation of the model | pypureclient/flasharray/FA_2_5/models/policy_rule_smb_client_get_response.py | to_str | Flav-STOR-WL/py-pure-client | python | def to_str(self):
return pprint.pformat(self.to_dict()) |
def __repr__(self):
'For `print` and `pprint`'
return self.to_str() | -8,960,031,694,814,905,000 | For `print` and `pprint` | pypureclient/flasharray/FA_2_5/models/policy_rule_smb_client_get_response.py | __repr__ | Flav-STOR-WL/py-pure-client | python | def __repr__(self):
return self.to_str() |
def __eq__(self, other):
'Returns true if both objects are equal'
if (not isinstance(other, PolicyRuleSmbClientGetResponse)):
return False
return (self.__dict__ == other.__dict__) | 7,993,875,800,545,782,000 | Returns true if both objects are equal | pypureclient/flasharray/FA_2_5/models/policy_rule_smb_client_get_response.py | __eq__ | Flav-STOR-WL/py-pure-client | python | def __eq__(self, other):
if (not isinstance(other, PolicyRuleSmbClientGetResponse)):
return False
return (self.__dict__ == other.__dict__) |
def __ne__(self, other):
'Returns true if both objects are not equal'
return (not (self == other)) | 7,764,124,047,908,058,000 | Returns true if both objects are not equal | pypureclient/flasharray/FA_2_5/models/policy_rule_smb_client_get_response.py | __ne__ | Flav-STOR-WL/py-pure-client | python | def __ne__(self, other):
return (not (self == other)) |
def combine_all_subsets(subsets):
"Merges N subsets into one. Strips top level 'name' and 'fields' keys as well as non-ECS field options since we can't know how to merge those."
merged_subset = {}
for subset in subsets:
strip_non_ecs_options(subset['fields'])
merge_subsets(merged_subset, sub... | -5,836,347,463,631,856,000 | Merges N subsets into one. Strips top level 'name' and 'fields' keys as well as non-ECS field options since we can't know how to merge those. | scripts/schema/subset_filter.py | combine_all_subsets | 6un9-h0-Dan/ecs | python | def combine_all_subsets(subsets):
merged_subset = {}
for subset in subsets:
strip_non_ecs_options(subset['fields'])
merge_subsets(merged_subset, subset['fields'])
return merged_subset |
def eval_globs(globs):
'Accepts an array of glob patterns or file names, returns the array of actual files'
all_files = []
for g in globs:
new_files = glob.glob(g)
if (len(new_files) == 0):
warn('{} did not match any files'.format(g))
else:
all_files.extend(ne... | -7,410,213,171,083,965,000 | Accepts an array of glob patterns or file names, returns the array of actual files | scripts/schema/subset_filter.py | eval_globs | 6un9-h0-Dan/ecs | python | def eval_globs(globs):
all_files = []
for g in globs:
new_files = glob.glob(g)
if (len(new_files) == 0):
warn('{} did not match any files'.format(g))
else:
all_files.extend(new_files)
return all_files |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.