id
stringlengths
30
32
content
stringlengths
139
2.8k
codereview_new_python_data_12875
def log_error(msg: str) -> None: *( asyncio.create_task( entry.async_setup(hass, integration=integration), - name=f"setup entry {entry.title} {entry.domain} {entry.entry_id}", ) for entry in hass.config_entries.asyn...
codereview_new_python_data_12876
def __init__( ) self._listeners: dict[CALLBACK_TYPE, tuple[CALLBACK_TYPE, object | None]] = {} - job_name = f"DataUpdateCoordinator {name}" if entry := self.config_entry: job_name += f" {entry.title} {entry.domain} {entry.entry_id}" self._job = HassJob(self._ha...
codereview_new_python_data_12877
def __init__( device: dict[str, Any], ) -> None: """Initialize the Livisi Climate.""" - super().__init__(config_entry, coordinator, device) self._target_temperature_capability = self.capabilities["RoomSetpoint"] self._temperature_capability = self.capabilities["RoomTem...
codereview_new_python_data_12878
def device_class(self) -> SensorDeviceClass | None: def _numeric_state_expected(self) -> bool: """Return true if the sensor must be numeric.""" device_class = try_parse_enum(SensorDeviceClass, self.device_class) - if device_class in {*NON_NUMERIC_DEVICE_CLASSES}: return False...
codereview_new_python_data_12879
def device_class(self) -> SensorDeviceClass | None: @property def _numeric_state_expected(self) -> bool: """Return true if the sensor must be numeric.""" device_class = try_parse_enum(SensorDeviceClass, self.device_class) if device_class in NON_NUMERIC_DEVICE_CLASSES: ...
codereview_new_python_data_12880
class AuroraSensor(AuroraEntity, SensorEntity): """Implementation of an aurora sensor.""" _attr_native_unit_of_measurement = PERCENTAGE @property def native_value(self): """Return % chance the aurora is visible.""" return self.coordinator.data - - @property - def state_c...
codereview_new_python_data_12881
LOGGER = logging.getLogger(__package__) -PLATFORMS: Final = [Platform.SENSOR, Platform.BUTTON] We usually try to keep these in alphabetical order. ```suggestion PLATFORMS: Final = [Platform.BUTTON, Platform.SENSOR] ``` LOGGER = logging.getLogger(__package__) +PLATFORMS: Final = [Platform.BUTTON, Platfo...
codereview_new_python_data_12882
async def async_set_temperature(self, **kwargs: Any) -> None: OverkizCommandParam.FURTHER_NOTICE, ) - async def async_set_hvac_mode(self, hvac_mode: str) -> None: """Set new target hvac mode.""" return `hvac_mode` should be of type `HVACMode` ```suggestion async de...
codereview_new_python_data_12883
def __init__( reolink_data: ReolinkData, coordinator: DataUpdateCoordinator[_T], ) -> None: - """Initialize ReolinkBaseCoordinatorEntity for a NVR entity without a channel.""" super().__init__(coordinator) self._host = reolink_data.host ```suggestion """Initi...
codereview_new_python_data_12884
def async_create_entity(event: ItemEvent, obj_id: str) -> None: @callback def async_options_updated() -> None: - """Load new entities based on changed options..""" async_add_unifi_entity(list(api_handler)) self.config_entry.async_on_unload( ``...
codereview_new_python_data_12885
def _async_init_flow( # as ones in progress as it may cause additional device probing # which can overload devices since zeroconf/ssdp updates can happen # multiple times in the same minute - if hass.config_entries.flow.async_has_matching_flow(domain, context, data): - return None - - if ha...
codereview_new_python_data_12886
def iter_schemas() -> Generator[MatterDiscoverySchema, None, None]: """Iterate over all available discovery schemas.""" for platform_schemas in DISCOVERY_SCHEMAS.values(): - for schema in platform_schemas: - yield schema @callback ```suggestion yield from platform_schemas `...
codereview_new_python_data_12887
async def setup_again(*_: Any) -> None: await self._async_process_on_unload() return - except (asyncio.CancelledError, Exception): # pylint: disable=broad-except _LOGGER.exception( "Error setting up entry %s for %s", self.title, integration.domain ...
codereview_new_python_data_12888
from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant -from homeassistant.helpers.typing import ConfigType -from .const import CONF_OBIHAI_HOST, PLATFORMS - -__all__ = [ - "CONF_OBIHAI_HOST", -] - - -def setup(hass: HomeAssistant, config: ConfigType) -> bool: - "...
codereview_new_python_data_12889
from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant -from homeassistant.helpers.typing import ConfigType -from .const import CONF_OBIHAI_HOST, PLATFORMS - -__all__ = [ - "CONF_OBIHAI_HOST", -] - - -def setup(hass: HomeAssistant, config: ConfigType) -> bool: - "...
codereview_new_python_data_12890
class ObihaiFlowHandler(ConfigFlow, domain=DOMAIN): VERSION = 1 - def __init__(self) -> None: - """Initialize.""" - self._host: str | None = None - async def async_step_user( self, user_input: dict[str, Any] | None = None ) -> FlowResult: `self._host` is never set ```sugg...
codereview_new_python_data_12891
LOGGER = logging.getLogger(__package__) -CONF_OBIHAI_HOST: Final = "host" PLATFORMS: Final = [Platform.SENSOR] Why not use the global `CONF_HOST` constant? LOGGER = logging.getLogger(__package__) PLATFORMS: Final = [Platform.SENSOR]
codereview_new_python_data_12892
def icon(self): return "mdi:restart-alert" return "mdi:phone" - def update(self) -> bool: """Update the sensor.""" if self._pyobihai.check_account(): services = self._pyobihai.get_state() Why return a bool? ```suggestion def update(self) -> None: ``` ...
codereview_new_python_data_12893
def icon(self): return "mdi:restart-alert" return "mdi:phone" - def update(self) -> bool: """Update the sensor.""" if self._pyobihai.check_account(): services = self._pyobihai.get_state() You can return early here instead, and un-indent: ```suggestion ...
codereview_new_python_data_12894
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: otbrdata = OTBRData(entry.data["url"], api) try: dataset = await otbrdata.get_active_dataset_tlvs() - except (asyncio.TimeoutError, aiohttp.ClientError) as err: raise ConfigEntryNotReady("Unable to connect") fr...
codereview_new_python_data_12895
async def _node_id_from_ha_device_id(ha_device_id: str) -> int | None: device = dev_reg.async_get(ha_device_id) if device is None: return None - return await get_node_from_device_entry(hass, device) async def open_commissioning_window(call: ServiceCall) -> None: ""...
codereview_new_python_data_12896
def __init__(self, entry_id: str, system: LiteJet, i: int, name: str) -> None: identifiers={(DOMAIN, f"{entry_id}_keypad_{keypad_number}")}, name=f"Keypad #{keypad_number}", manufacturer="Centralite", ) async def async_added_to_hass(self) -> None: ```suggestion ...
codereview_new_python_data_12897
@callback def exclude_attributes(hass: HomeAssistant) -> set[str]: - """Exclude event_id from being recorded in the database.""" return {ATTR_EVENT_ID, ATTR_EVENT_SCORE} ```suggestion """Exclude event_id and event_score from being recorded in the database.""" ``` @callback def exclude_attribut...
codereview_new_python_data_12898
def exclude_attributes(hass: HomeAssistant) -> set[str]: "Time to Empty", "Time to Full Charge", # Android mobile app "Free internal storage", "current", "voltage", Ideally we exclude `android.*` but we don't support wildcards here and I'm not 100% sure we want to...
codereview_new_python_data_12899
async def test_lru_increases_with_many_entities( """Test that the recorder's internal LRU cache increases with many entities.""" # We do not actually want to record 4096 entities, so we mock the recorder # to not actually record anything. - with patch( - "homeassistant.components.recorder.Reco...
codereview_new_python_data_12900
CONF_IS_APPARENT_POWER = "is_apparent_power" CONF_IS_AQI = "is_aqi" -CONF_IS_ATMOSPHERIC_PRESSURE = "atmospheric_pressure" CONF_IS_BATTERY_LEVEL = "is_battery_level" CONF_IS_CO = "is_carbon_monoxide" CONF_IS_CO2 = "is_carbon_dioxide" The value for "atmospheric_pressure" is incorrect. It is being adjusted in #...
codereview_new_python_data_12901
JSON_ENCODE_EXCEPTIONS = (TypeError, ValueError) JSON_DECODE_EXCEPTIONS = (orjson.JSONDecodeError,) json_loads: Callable[[bytes | bytearray | memoryview | str], JsonValueType] json_loads = orjson.loads """Parse JSON data.""" Maybe we should keep `WriteError` declared inside util to avoid breaking change JSO...
codereview_new_python_data_12902
async def test_washer_sensor_values( assert entry assert entry.disabled assert entry.disabled_by is entity_registry.RegistryEntryDisabler.INTEGRATION - update_entry = registry.async_update_entity( - entry.entity_id, **{"disabled_by": None} - ) await hass.async_block_till_done() as...
codereview_new_python_data_12903
# stubbing out for integrations that have # not yet been updated for python 3.11 # but can still run on python 3.10 from asyncio import base_futures, constants, format_helpers from asyncio.coroutines import _is_coroutine import collections.abc ```suggestion # but can still run on python 3.10 # # Remove this ...
codereview_new_python_data_12904
async def async_setup_entry( entry: ConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: - """Set up the lock platform for Dormakaba dKey.""" data: DormakabaDkeyData = hass.data[DOMAIN][entry.entry_id] async_add_entities( DormakabaDkeyBinarySensor(data.coordinator, data.loc...
codereview_new_python_data_12905
def mock_storage( orig_load = storage.Store._async_load - async def mock_async_load(store: storage.Store) -> None: """Mock version of load.""" if store._data is None: # No data to load This will return the storage generic type of the stored data. https://github.com/home-a...
codereview_new_python_data_12906
class ClassTypeHintMatch: "mock_device_tracker_conf": "list[Device]", "mock_get_source_ip": "None", "mock_hass_config": "None", - "mock_zeroconf": "None", "mock_hass_config_yaml": "None", "mqtt_client_mock": "MqttMockPahoClient", "mqtt_mock": "MqttMockHAClient", "mqtt_mock_entry_n...
codereview_new_python_data_12907
async def test_wait_for_trigger_variables(hass: HomeAssistant) -> None: actions = [ { "alias": "variables", - "variables": {"seconds": 0.01}, }, { "alias": wait_alias, "wait_for_trigger": { - "platform": "state", - ...
codereview_new_python_data_12908
class ReolinkSelectEntityDescription( key="ptz_preset", name="PTZ preset", icon="mdi:pan", - get_options=lambda api, ch: list(api.ptz_presets(ch).keys()), supported=lambda api, ch: api.supported(ch, "ptz_presets"), method=lambda api, ch, name: api.set_ptz_command(ch,...
codereview_new_python_data_12909
def _update_tilt(self, result): @property def is_closed(self) -> bool | None: """Return if the cover is closed.""" - if not self._position_template and not self._template and not self._optimistic: return None - return self._position == 0 @property Should this che...
codereview_new_python_data_12910
async def async_turn_off(self, **kwargs: Any) -> None: key="stowed", name="Stowed", device_class=SwitchDeviceClass.SWITCH, - entity_registry_enabled_default=False, value_fn=lambda data: data.status["state"] == "STOWED", turn_on_fn=lambda coordinator: coordinator.asyn...
codereview_new_python_data_12911
async def async_setup_entry( class ReolinkUpdateEntity(ReolinkBaseCoordinatorEntity, UpdateEntity): """Update entity for a Netgear device.""" - _attr_has_entity_name = True _attr_device_class = UpdateDeviceClass.FIRMWARE _attr_supported_features = UpdateEntityFeature.INSTALL You could move `_at...
codereview_new_python_data_12912
async def async_handle(self, intent_obj: Intent) -> IntentResponse: if not states: raise IntentHandleError( - "No entities matched for: " f"name={name}, " f"area={area}, ", - f"domains={domains}, " f"device_classes={device_classes}", ) respo...
codereview_new_python_data_12913
def _ha_orm_quote(mixed, ident): made_url = sa.make_url(db_url) db = made_url.database engine = sa.create_engine(db_url) - # Kill any open connections to the database before dropping it # to ensure that InnoDB does not deadlock. with engine.begin() as connection: ...
codereview_new_python_data_12914
def override_async_setup_entry() -> Generator[AsyncMock, None, None]: @pytest.fixture -def filled_device_registry( hass: HomeAssistant, config_entry: ConfigEntry ) -> dr.DeviceRegistry: """Fill device registry with mock devices.""" We're using the async api so we should make sure the fixture runs insi...
codereview_new_python_data_12915
class ClassTypeHintMatch: "caplog": "pytest.LogCaptureFixture", "device_registry": "DeviceRegistry", "entity_registry": "EntityRegistry", - "issue_registry": "IssueRegistry", "hass_client": "ClientSessionGenerator", "hass_client_no_auth": "ClientSessionGenerator", "hass_ws_client": "We...
codereview_new_python_data_12916
async def async_process_audio_stream( @pytest.fixture -def test_provider() -> None: """Test provider fixture.""" return TestProvider() This fixture does not return `None` async def async_process_audio_stream( @pytest.fixture +def test_provider(): """Test provider fixture.""" return T...
codereview_new_python_data_12917
def visit_functiondef(self, node: nodes.FunctionDef) -> None: self._check_function(node, match, annotations) # Check method matchers. - if node.is_method(): - for match in _METHOD_MATCH["__any_class__"]: - if not match.need_to_check_function(node): - ...
codereview_new_python_data_12918
async def async_setup_entry( ) -> None: """Set up the lock platform for Dormakaba dKey.""" data: DormakabaDkeyData = hass.data[DOMAIN][entry.entry_id] - async_add_entities([DormakabaDkeyLock(data.coordinator, data.lock, entry.title)]) -class DormakabaDkeyLock(CoordinatorEntity, LockEntity): """R...
codereview_new_python_data_12919
async def async_setup_entry( ) -> None: """Set up the lock platform for Dormakaba dKey.""" data: DormakabaDkeyData = hass.data[DOMAIN][entry.entry_id] - async_add_entities([DormakabaDkeyLock(data.coordinator, data.lock, entry.title)]) -class DormakabaDkeyLock(CoordinatorEntity, LockEntity): """R...
codereview_new_python_data_12920
class DormakabaDkeyData: title: str lock: DKEYLock - coordinator: DataUpdateCoordinator ```suggestion coordinator: DataUpdateCoordinator[None] ``` class DormakabaDkeyData: title: str lock: DKEYLock + coordinator: DataUpdateCoordinator[None]
codereview_new_python_data_12921
async def async_setup_entry( async_add_entities: AddEntitiesCallback, ) -> None: """Set up entry.""" - entities = list[ScreenLogicSensorEntity]() coordinator = hass.data[DOMAIN][config_entry.entry_id] equipment_flags = coordinator.gateway.get_data()[SL_DATA.KEY_CONFIG][ "equipment_flag...
codereview_new_python_data_12922
async def async_setup_entry( async_add_entities: AddEntitiesCallback, ) -> None: """Set up entry.""" - entities = list[ScreenLogicBinarySensorEntity]() coordinator = hass.data[DOMAIN][config_entry.entry_id] # Generic binary sensor This typing doesn't look right async def async_setup_entr...
codereview_new_python_data_12923
async def async_setup_entry( async_add_entities: AddEntitiesCallback, ) -> None: """Set up entry.""" - entities = list[ScreenLogicBinarySensorEntity]() coordinator = hass.data[DOMAIN][config_entry.entry_id] # Generic binary sensor ```suggestion entities: list[ScreenLogicBinarySensorEnti...
codereview_new_python_data_12924
# C=0: General purpose objects # D=0: Free ID-numbers for utilities # E=0 Ownership ID - SensorEntityDescription(key="1-0:0.0.0*255", name="Ownership ID", icon="mdi:flash"), # E=9: Electrity ID SensorEntityDescription( key="1-0:0.0.9*255", name="Electricity ID", icon="mdi:flash" I...
codereview_new_python_data_12925
def __init__( ) -> None: """Initialize the Yale Lock Device.""" super().__init__(coordinator, data) - self._attr_code_format = "^\\d{" + str(code_format) + "}$" self.lock_name: str = data["name"] async def async_unlock(self, **kwargs: Any) -> None: Please use f-strings......
codereview_new_python_data_12926
async def async_step_hassio(self, discovery_info: HassioServiceInfo) -> FlowResu api = python_otbr_api.OTBR(url, async_get_clientsession(self.hass), 10) try: if await api.get_active_dataset_tlvs() is None: - await api.async_create_active_dataset( pytho...
codereview_new_python_data_12927
class NAMSensorEntityDescription(SensorEntityDescription, NAMSensorRequiredKeysM device_class=SensorDeviceClass.TIMESTAMP, entity_registry_enabled_default=False, entity_category=EntityCategory.DIAGNOSTIC, - value=lambda sensors: utcnow() - - timedelta(seconds=getattr(sensors, "...
codereview_new_python_data_12928
def is_numeric(self) -> bool: """Return true if the sensor is numeric.""" if ( self.state_class is not None - or self.unit_of_measurement is not None or self.native_precision is not None ): return True I think this should use the native unit...
codereview_new_python_data_12929
async def async_added_to_hass(self) -> None: def message_received(message): """Handle new MQTT messages.""" if message.payload == "": - # On empty payload, reset the sensor value or ignore update - if self._attr_native_value is not None: - ...
codereview_new_python_data_12930
async def async_setup_platform( [ GeniusSwitch(broker, z) for z in broker.client.zone_objs - if 'type' in z.data and z.data["type"] == GH_ON_OFF_ZONE ] ) ```suggestion if z.data.get("type") == GH_ON_OFF_ZONE ``` async def async_setup_platfo...
codereview_new_python_data_12931
def system_set(cloud_enabled): async def test_switch_handles_requesterror( hass, mock_config_entry_data, mock_config_entry ): - """Test entity pytest.raises HomeAssistantError when RequestError was raised.""" api = get_mock_device(product_type="HWE-SKT", firmware_version="3.02") api.state = Async...
codereview_new_python_data_12932
def _migrate_columns_to_timestamp( ) ) elif engine.dialect.name == SupportedDialect.MYSQL: - # With MySQL we do this in chunks to avoid locking the table for too long. # We also need to do this in a loop since we can't be sure that we have # updated all rows in the t...
codereview_new_python_data_12933
class AttributeEnumMapping(NamedTuple): attr_name=ATTR_MODE, name="Mode", set_method="set_mode", - set_method_error_message="Setting the mode of the fan", icon="mdi:fan", translation_key="mode", options=["silent", "auto", "favorite"], ```suggestion ...
codereview_new_python_data_12934
class AttributeEnumMapping(NamedTuple): attr_name=ATTR_MODE, name="Mode", set_method="set_mode", - set_method_error_message="Setting the mode of the fan", icon="mdi:fan", translation_key="mode", options=["silent", "auto", "favorite"], Should these also be u...
codereview_new_python_data_12935
async def async_step_user( _LOGGER.exception("Unexpected exception") errors["base"] = "unknown" else: - return self.async_create_entry(title="", data=user_input) return self.async_show_form( step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=...
codereview_new_python_data_12936
You are a conversational AI for a smart home named {{ ha_name }}. If a user wants to control a device, reject the request and suggest using the Home Assistant UI. -The people living in this smart home are: - -{% for state in states.person -%} -- {{ state.name }} is {{state.state}} -{%- endfor %} - An overview of ...
codereview_new_python_data_12937
def _handle_coordinator_update(self) -> None: class SwitchBotBlindTiltEntity(SwitchbotEntity, CoverEntity, RestoreEntity): """Representation of a Switchbot.""" - _device: switchbot.SwitchbotCurtain _attr_device_class = CoverDeviceClass.CURTAIN _attr_supported_features = ( CoverEntityFeatu...
codereview_new_python_data_12938
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: - """Set up the Thread integration.""" if not hass.config_entries.async_entries(DOMAIN): hass.async_create_task( hass.config_entries.flow.async_init( extra space in doc string async def async_setup(hass:...
codereview_new_python_data_12939
class HoneywellSensorEntityDescription( SENSOR_TYPES: tuple[HoneywellSensorEntityDescription, ...] = ( HoneywellSensorEntityDescription( key=TEMPERATURE_STATUS_KEY, - name="Outdoor Temperature", device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT...
codereview_new_python_data_12940
async def test_scene_activate(hass, scene): assert state.attributes["icon"] == scene.icon assert state.attributes["color"] == scene.color assert state.attributes["location_id"] == scene.location_id - # pylint: disable-next=protected-access assert scene.execute.call_count == 1 # type: ignore ...
codereview_new_python_data_12941
async def async_step_user( await self.async_set_unique_id(DOMAIN) return self.async_create_entry( title="Thread", - data={"url": url}, ) data_schema = vol.Schema({CONF_URL: str}) Already guarded by the schema, so we ...
codereview_new_python_data_12942
def __init__( self.entity_description = entity_description self._unsubscribes: list[Callable] = [] # for fast lookups we create a mapping to the attribute paths self._attributes_map: dict[type, str] = {} server_info = cast(ServerInfo, self.matter_client.server_info) - ...
codereview_new_python_data_12943
def get_operational_instance_id( node: MatterNode, ) -> str: """Return `Operational Instance Name` for given MatterNode.""" - fab_id_hex = f"{server_info.compressed_fabric_id:016X}" node_id_hex = f"{node.node_id:016X}" # operational instance id matches the mdns advertisement for the node #...
codereview_new_python_data_12944
def __init__( description: NumberEntityDescription, device_info: DeviceInfo | None, ) -> None: - """Initialize the ISY Backlight Select entity.""" super().__init__(node, control, unique_id, description, device_info) self._attr_native_value = 0 ```suggestion "...
codereview_new_python_data_12945
async def _telnet_callback(self, zone, event, parameter): if zone != self._receiver.zone: return - self.async_schedule_update_ha_state(False) async def async_will_remove_from_hass(self) -> None: """Clean up the entity.""" ```suggestion self.async_write_ha_state(...
codereview_new_python_data_12946
def device_class(self) -> SensorDeviceClass | None: if self.entity_description.device_class_fn: # Note: using self.state could infloop here. return self.entity_description.device_class_fn(self.native_value) - return self.entity_description.device_class @property de...
codereview_new_python_data_12947
async def test_integration_reload( @pytest.mark.parametrize("do_config", [{}]) async def test_integration_reload_failed(hass, caplog, mock_modbus) -> None: - """Test setup fails.""" caplog.set_level(logging.INFO) caplog.clear() Minor tweak - looks good otherwise. ```suggestion """Run test for...
codereview_new_python_data_13011
def _RenderConfig(vm, # scale with the cluster. num_reduce_tasks = reduces_per_node * num_workers if _BLOCKSIZE_OVERRIDE.value: - block_size = _BLOCKSIZE_OVERRIDE * 1024 * 1024 if vm.scratch_disks: # TODO(pclay): support multiple scratch disks. A current suboptimal ```suggestion block_size ...
codereview_new_python_data_13012
def _PullJobMetrics(self, force_refresh=False): return # Raise exception if job id not available if self.job_id is None: - raise ValueError('Unable to pull job metrics. Job ID not available') cmd = util.GcloudCommand(self, 'dataflow', 'metrics', 'list', sel...
codereview_new_python_data_13019
def _create_workspace(self, ws_2D=True, sample=True, xAx=True, yAxSpec=True, yAx if not yAxMt and not yAxSpec: ws = CreateWorkspace(DataX=self.data_x, DataY=self.data_y, DataE=np.sqrt(self.data_y), NSpec=1, UnitX="DeltaE") LoadInstrument(ws, True, InstrumentName="TOFTOF") - ...
codereview_new_python_data_13022
def waterfall_reverse_line_order(self): for cap in errorbar_cap_lines: ax.add_line(cap) - if LooseVersion("3.7") > LooseVersion(matplotlib.__version__) >= LooseVersion("3.2"): - for line_fill in fills: - if line_fill not in ax.collections: - a...
codereview_new_python_data_13028
def plot( legend = ax.get_legend() if legend is not None: legend.set_visible(show_legend) - # Stop legend messing with the tight layout legend.set_in_layout(False) # Can't have a waterfall plot with only one line. ```suggestion # Stop legend i...
codereview_new_python_data_13031
from qtpy.QtCore import Slot from qtpy.QtGui import QIcon class DetachableTabWidget(QtWidgets.QTabWidget): """ I think we should keep this acknowledgement of the "borrowed" code from qtpy.QtCore import Slot from qtpy.QtGui import QIcon +""" +Original code by user Blackwood, Jan 2018. +https://stacko...
codereview_new_python_data_13037
def _cut_names(self, cut: str): return xcut_name, ycut_name, help_msg - @staticmethod - def get_dim_indices(slice_point: List[float], qdims: List[int], transpose: bool) -> Tuple[int]: - """Returns the indices of the selected x and y axes. It also returns the index of the first non x or y axis...
codereview_new_python_data_13038
def get_hkl_from_full_point(self, full_point: List[float], qdims_i: List[int]): if basis_transform is None: return 0.0, 0.0, 0.0 - # Get the values for the h, k and l projections - hkl_projection = tuple(full_point[q_i] for q_i in qdims_i) - return np.matmul(basis_transfo...
codereview_new_python_data_13043
# Mantid Repository : https://github.com/mantidproject/mantid # -# Copyright © 2021 ISIS Rutherford Appleton Laboratory UKRI, # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0...
codereview_new_python_data_13044
# Mantid Repository : https://github.com/mantidproject/mantid # -# Copyright © 2021 ISIS Rutherford Appleton Laboratory UKRI, # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0...
codereview_new_python_data_13045
def _loadRun(self, run: str) -> MatrixWorkspace: self.log().information('Loaded workspace ') return ws, monitor_ws - def _applyCalibration(self, ws, calibration_filepath): alg = self.createChildAlgorithm('ReflectometryISISCalibration') alg.setProperty("InputWorkspace", ws) ...
codereview_new_python_data_13046
def test_algorithm_fails_for_invalid_block_names(self): Instrument='INTER', GetLiveValueAlgorithm='GetFakeLiveInstrumentValueInvalidNames') - def test_algorithm_fails_if_theta_is_zero(self): workspace = self._run_algorithm_with_zero_theta() e...
codereview_new_python_data_13047
def plot_real_lattice_vectors(plot_axes, real_lattice, colors): def calculate_lattice_vectors(workspace): ub_matrix = np.array(workspace.sample().getOrientedLattice().getUB()) - hkl = np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]) q_sample = np.matmul(ub_matrix, hkl) goniometer = wo...
codereview_new_python_data_13048
# Mantid Repository : https://github.com/mantidproject/mantid # -# Copyright © 202 ISIS Rutherford Appleton Laboratory UKRI, # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 ...
codereview_new_python_data_13051
# Mantid Repository : https://github.com/mantidproject/mantid # -# Copyright © 2020 ISIS Rutherford Appleton Laboratory UKRI, # NScD Oak Ridge National Laboratory, European Spallation Source # & Institut Laue - Langevin # SPDX - License - Identifier: GPL - 3.0 + Since this is a new file, the copyrig...
codereview_new_python_data_13052
def test_hide_button_hides_window(self, mock_qappthread): fig_manager = FigureManagerWorkbench(canvas, 1) # This is only called when show() is called on the figure manager, so we have to manually call it here. fig_manager.toolbar.set_buttons_visibility(fig) fig_manager.toolbar.hide_...
codereview_new_python_data_13054
def keyPressEvent(self, event): QTableView.keyPressEvent(self, event) self._key_handler._row_selected() - def set_concise(self, bl): - self.is_concise = bl - def enable_sorting(self, sort_role: int): """ Turn on column sorting by clicking headers Might be mistaken ...
codereview_new_python_data_13055
def on_visibility_changed(self, visible): def on_normalise_checked(self, checked): """ Transmit the normalisation checkbox state to the model. """ self._model.normalise(checked) self._update_plot(True) Docstring for `checked` is missing here. def on_visibility_chang...
codereview_new_python_data_13056
def block_end(file_obj: BufferedReader, *, msg: Sequence[str]) -> bool: Checks for msg which terminates block. :param file_obj: file object from which we read - :param msg: list of messages which can end kpoint block. :returns: True if end of block otherwise False """ ...
codereview_new_python_data_13057
def is_normalised(self) -> bool: if not np.allclose(np.ones(displacements.shape[1]), norm(norm(displacements, axis=0), axis=1)): return False - else: - return True def extract(self): extracted = {"unit_cell": self.unit_cell...
codereview_new_python_data_13058
def update_line_plot_limits(self): """ # ensure plot labels are in sync with main axes self._axx.relim() self._axy.relim() def update_line_plot_labels(self): """ How were these causing a problem? It seems to behave fine on a nightly version for me. def update_line...
codereview_new_python_data_13059
def eiWavelengthUpdateEvent(self): self.dimensionWidget.set_editMax4(upperBound) def instrumentUpdateEvent(self): - changeToElastic = True if self.masterDict['instrument'] in ['WAND\u00B2'] else False - if changeToElastic: - self.dimensionWidget.toggleDeltaE(False) - ...
codereview_new_python_data_13060
def eiWavelengthUpdateEvent(self): self.dimensionWidget.set_editMax4(upperBound) def instrumentUpdateEvent(self): - changeToElastic = True if self.masterDict['instrument'] in ['WAND\u00B2'] else False - if changeToElastic: - self.dimensionWidget.toggleDeltaE(False) - ...
codereview_new_python_data_13061
def get_proj_matrix(self): # for histo try to find axes from log try: expt_info = ws.getExperimentInfo(0) - trans_matrix = np.array(expt_info.run().get(PROJ_MATRIX_LOG_NAME).value, dtype=float).reshape(3, 3) - ...
codereview_new_python_data_13062
def test_calculate_axes_angles_uses_W_if_available_MDEvent(self): axes_angles = model.get_axes_angles(force_orthogonal=True) self.assertAlmostEqual(axes_angles[1, 2], np.pi / 2, delta=1e-10) - def test_calculate_axes_angles_uses_W_if_available_MDHisto(self): #test MD histo ws =...
codereview_new_python_data_13064
def get_default_scale_norm(self): scale = self.conf.get(SCALENORM, type=str) if scale == 'Power' and self.conf.has(POWERSCALE): - exponent = self.conf.get(POWERSCALE) scale = (scale, exponent) scale = "SymmetricLog10" if scale == 'Log' else scale I think this...
codereview_new_python_data_13065
def generate_ts_pdf(run_number, focus_file_path, sample_details, placzek_order, raw_ws = mantid.Load(Filename='POLARIS'+str(run_number)) sample_geometry_json = sample_details.generate_sample_geometry() - # import pydevd_pycharm - # pydevd_pycharm.settrace('localhost', port=8080, stdoutToServer=True, ...