Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions hexrdgui/azimuthal_overlay_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def create_materials_combo(self, v: str) -> QWidget:
raise Exception(f'Unknown material: {v}')

cb = QComboBox(self.ui.table)
size_policy = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
size_policy = QSizePolicy(
QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding
)
cb.setSizePolicy(size_policy)
for mat in materials:
cb.addItem(mat, mat)
Expand Down Expand Up @@ -158,7 +160,10 @@ def select_row(self, i: int | None) -> None:
selection_model.clearSelection()

model_index = selection_model.model().index(i, 0)
command = QItemSelectionModel.SelectionFlag.Select | QItemSelectionModel.SelectionFlag.Rows
command = (
QItemSelectionModel.SelectionFlag.Select
| QItemSelectionModel.SelectionFlag.Rows
)
selection_model.select(model_index, command)

@property
Expand Down
4 changes: 3 additions & 1 deletion hexrdgui/brightness_contrast_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ def select_data_range(self) -> None:
range_widget.max = self.data_range[1]
layout.addWidget(range_widget.ui)

buttons = QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
buttons = (
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
)
button_box = QDialogButtonBox(buttons, dialog)
button_box.accepted.connect(dialog.accept)
button_box.rejected.connect(dialog.reject)
Expand Down
13 changes: 11 additions & 2 deletions hexrdgui/cal_tree_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ def __init__(self, parent: QWidget | None = None) -> None:
self.cfg = HexrdConfig()
self.rebuild_tree()

def data(self, index: QModelIndex | QPersistentModelIndex, role: int = Qt.ItemDataRole.DisplayRole) -> Any:
def data(
self,
index: QModelIndex | QPersistentModelIndex,
role: int = Qt.ItemDataRole.DisplayRole,
) -> Any:
if not index.isValid():
return None

Expand All @@ -49,7 +53,12 @@ def data(self, index: QModelIndex | QPersistentModelIndex, role: int = Qt.ItemDa

return value

def setData(self, index: QModelIndex | QPersistentModelIndex, value: Any, role: int = Qt.ItemDataRole.EditRole) -> bool:
def setData(
self,
index: QModelIndex | QPersistentModelIndex,
value: Any,
role: int = Qt.ItemDataRole.EditRole,
) -> bool:
item = self.get_item(index)
path = self.path_to_value(item, index.column())

Expand Down
4 changes: 3 additions & 1 deletion hexrdgui/calibration/calibration_dialog_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ def pop_undo_stack(self) -> None:
def update_undo_enable_state(self) -> None:
self.dialog.undo_enabled = bool(self.undo_stack)

def on_relative_constraints_changed(self, new_constraint: RelativeConstraintsType) -> None:
def on_relative_constraints_changed(
self, new_constraint: RelativeConstraintsType
) -> None:
self.calibrator.relative_constraints_type = new_constraint
self.restore_constraint_params()
# Reset the tilt center of rotation in the dialog
Expand Down
4 changes: 3 additions & 1 deletion hexrdgui/calibration/calibration_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,9 @@ def load_picks_from_file(self, selected_file: str) -> dict[str, Any]:


@contextmanager
def zoom_canvas_disabled(line_picker: LinePickerDialog | None) -> Generator[None, None, None]:
def zoom_canvas_disabled(
line_picker: LinePickerDialog | None,
) -> Generator[None, None, None]:
if line_picker:
prev = line_picker.zoom_canvas.disabled
line_picker.zoom_canvas.disabled = True
Expand Down
4 changes: 3 additions & 1 deletion hexrdgui/calibration/polarview.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ def func_project_on_detector(self, detector: Detector) -> Callable[..., Any]:
else:
return _project_on_detector_plane

def args_project_on_detector(self, detector: Detector) -> tuple[tuple[Any, ...], dict[str, Any]]:
def args_project_on_detector(
self, detector: Detector
) -> tuple[tuple[Any, ...], dict[str, Any]]:
"""
prepare the arguments to be passed for
mapping to plane or cylinder
Expand Down
4 changes: 3 additions & 1 deletion hexrdgui/calibration/structureless/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ def _hand_picking_finished(self) -> None:
# will not be left in an invalid state.
self.set_focus_mode(False)

def show_calibration_dialog(self, calibrator_lines: dict[str, Any]) -> CalibrationDialog:
def show_calibration_dialog(
self, calibrator_lines: dict[str, Any]
) -> CalibrationDialog:
self.previous_picks_data = calibrator_lines

engineering_constraints = guess_engineering_constraints(self.instr)
Expand Down
33 changes: 27 additions & 6 deletions hexrdgui/calibration/tree_item_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ def convert_if_needed(v: Any) -> Any:
# Trigger the callback function
param._on_vary_modified()

def data(self, index: QModelIndex | QPersistentModelIndex, role: int = Qt.ItemDataRole.DisplayRole) -> Any:
def data(
self,
index: QModelIndex | QPersistentModelIndex,
role: int = Qt.ItemDataRole.DisplayRole,
) -> Any:
if (
role in (Qt.ItemDataRole.BackgroundRole, Qt.ItemDataRole.ForegroundRole)
and index.column() in (self.VALUE_IDX, self.VARY_IDX)
Expand All @@ -117,7 +121,10 @@ def data(self, index: QModelIndex | QPersistentModelIndex, role: int = Qt.ItemDa
uneditable_path = tuple(self.path_to_item(item) + [self.VALUE_IDX])
if uneditable_path in self.uneditable_paths:
color = 'gray'
if index.column() == self.VALUE_IDX and role == Qt.ItemDataRole.ForegroundRole:
if (
index.column() == self.VALUE_IDX
and role == Qt.ItemDataRole.ForegroundRole
):
color = 'white'

return QColor(color)
Expand Down Expand Up @@ -164,8 +171,15 @@ class DefaultCalibrationTreeItemModel(CalibrationTreeItemModel):
MIN_IDX = COLUMN_INDICES['Minimum']
BOUND_INDICES = (VALUE_IDX, MAX_IDX, MIN_IDX)

def data(self, index: QModelIndex | QPersistentModelIndex, role: int = Qt.ItemDataRole.DisplayRole) -> Any:
if role == Qt.ItemDataRole.ForegroundRole and index.column() in self.BOUND_INDICES:
def data(
self,
index: QModelIndex | QPersistentModelIndex,
role: int = Qt.ItemDataRole.DisplayRole,
) -> Any:
if (
role == Qt.ItemDataRole.ForegroundRole
and index.column() in self.BOUND_INDICES
):
# If a value hit the boundary, color both the boundary and the
# value red.
item = self.get_item(index)
Expand Down Expand Up @@ -205,8 +219,15 @@ class DeltaCalibrationTreeItemModel(CalibrationTreeItemModel):
DELTA_IDX = COLUMN_INDICES['Delta']
BOUND_INDICES = (VALUE_IDX, DELTA_IDX)

def data(self, index: QModelIndex | QPersistentModelIndex, role: int = Qt.ItemDataRole.DisplayRole) -> Any:
if role == Qt.ItemDataRole.ForegroundRole and index.column() in self.BOUND_INDICES:
def data(
self,
index: QModelIndex | QPersistentModelIndex,
role: int = Qt.ItemDataRole.DisplayRole,
) -> Any:
if (
role == Qt.ItemDataRole.ForegroundRole
and index.column() in self.BOUND_INDICES
):
# If a delta is zero, color both the delta and the value red.
item = self.get_item(index)
if not item.child_items and item.data(self.VALUE_IDX) is not None:
Expand Down
12 changes: 9 additions & 3 deletions hexrdgui/calibration/wppf_options_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,9 @@ def tree_view_columns(self) -> dict:
return self.tree_view_model_class.COLUMNS

@property
def tree_view_model_class(self) -> type[DefaultWPPFTreeItemModel] | type[DeltaWPPFTreeItemModel]:
def tree_view_model_class(
self,
) -> type[DefaultWPPFTreeItemModel] | type[DeltaWPPFTreeItemModel]:
if self.delta_boundaries:
return DeltaWPPFTreeItemModel
else:
Expand Down Expand Up @@ -1746,7 +1748,9 @@ def wppf_object(self) -> LeBail | Rietveld:

return self._wppf_object

def create_wppf_object(self, reset_background_params: bool = False) -> LeBail | Rietveld:
def create_wppf_object(
self, reset_background_params: bool = False
) -> LeBail | Rietveld:
class_types = {
'LeBail': LeBail,
'Rietveld': Rietveld,
Expand Down Expand Up @@ -2282,7 +2286,9 @@ def is_zero(v: float) -> bool:

return False

def _copy_texture_figs(self, obj1: LeBail | Rietveld | None, obj2: LeBail | Rietveld | None) -> None:
def _copy_texture_figs(
self, obj1: LeBail | Rietveld | None, obj2: LeBail | Rietveld | None
) -> None:
# We need to keep the original texture figures, so copy those over.
if obj1 is None or obj2 is None:
return
Expand Down
8 changes: 6 additions & 2 deletions hexrdgui/dynamic_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class DynamicWidget(QObject):
# Emitted when the value is changed
value_changed = Signal()

def __init__(self, description: dict[str, Any], parent: QObject | None = None) -> None:
def __init__(
self, description: dict[str, Any], parent: QObject | None = None
) -> None:
super().__init__(parent)

self.description = description
Expand Down Expand Up @@ -60,7 +62,9 @@ def label_from_description(x: dict[str, Any]) -> QLabel | None:
return QLabel(x['label'])


def widget_from_description(x: dict[str, Any], parent: QWidget | None = None) -> QWidget | None:
def widget_from_description(
x: dict[str, Any], parent: QWidget | None = None
) -> QWidget | None:
"""Dynamically create a widget from a description dict.

Some of the keys currently accepted are 'type', 'min', 'max', and
Expand Down
4 changes: 3 additions & 1 deletion hexrdgui/fiber_pick_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ def _pick_to_fiber(
return qfib.T # (4, ndiv)


def _angles_from_orientation(instr: HEDMInstrument, eta_ome_maps: Any, orientation: Any) -> list:
def _angles_from_orientation(
instr: HEDMInstrument, eta_ome_maps: Any, orientation: Any
) -> list:
"""
Return the (eta, omega) angles for a specified orientation consistent with
input EtaOmeMaps.
Expand Down
5 changes: 4 additions & 1 deletion hexrdgui/hand_picked_fibers_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,10 @@ def select_rows(self, rows: list[int]) -> None:

with block_signals(selection_model):
selection_model.clearSelection()
command = QItemSelectionModel.SelectionFlag.Select | QItemSelectionModel.SelectionFlag.Rows
command = (
QItemSelectionModel.SelectionFlag.Select
| QItemSelectionModel.SelectionFlag.Rows
)

for i in rows:
if i is None or i >= table.rowCount():
Expand Down
4 changes: 3 additions & 1 deletion hexrdgui/html_delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def _add_stylesheet(self, html_content: str) -> str:
'</html>'
)

def _get_display_string(self, index: QModelIndex | QPersistentModelIndex) -> str | None:
def _get_display_string(
self, index: QModelIndex | QPersistentModelIndex
) -> str | None:
data = index.data(Qt.ItemDataRole.DisplayRole)
if data is not None and not isinstance(data, str):
# Ensure it is a string
Expand Down
11 changes: 6 additions & 5 deletions hexrdgui/image_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1818,9 +1818,7 @@ def save_azimuthal_plot(self) -> None:
assert self.azimuthal_integral_axis is not None
extent = self.azimuthal_integral_axis.get_window_extent().transformed(size)
# The bbox does not include the axis so manually scale it up so it does
new_extent = extent.from_extents(
0, 0, extent.xmax * 1.05, extent.ymax * 1.05
)
new_extent = extent.from_extents(0, 0, extent.xmax * 1.05, extent.ymax * 1.05)
# Save the clipped region of the figure
self.figure.savefig(selected_file, bbox_inches=new_extent)

Expand Down Expand Up @@ -2154,7 +2152,8 @@ def create_waterfall_plot(self) -> None:
# No close button in the corner
flags = progress.windowFlags()
progress.setWindowFlags(
(flags | Qt.WindowType.CustomizeWindowHint) & ~Qt.WindowType.WindowCloseButtonHint
(flags | Qt.WindowType.CustomizeWindowHint)
& ~Qt.WindowType.WindowCloseButtonHint
)

self._create_waterfall_progress = progress
Expand Down Expand Up @@ -2591,7 +2590,9 @@ def transform_from_plain_cartesian_func(mode: str) -> Callable:
def to_pixels(xys: np.ndarray, panel: Detector, iviewer: IViewer) -> np.ndarray:
return cart_to_pixels(xys, panel)

def transform_cart(xys: np.ndarray, panel: Detector, iviewer: IViewer) -> np.ndarray:
def transform_cart(
xys: np.ndarray, panel: Detector, iviewer: IViewer
) -> np.ndarray:
dplane = iviewer.dplane # type: ignore[union-attr]
return panel.map_to_plane(xys, dplane.rmat, dplane.tvec)

Expand Down
8 changes: 6 additions & 2 deletions hexrdgui/image_stack_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,13 @@ def load_omega_from_file(self, checked: bool) -> None:
self.ui.load_omega_file.setEnabled(checked)
self.ui.omega_file.setEnabled(checked)
if checked:
self.ui.omega_wedges.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers)
self.ui.omega_wedges.setEditTriggers(
QAbstractItemView.EditTrigger.NoEditTriggers
)
else:
self.ui.omega_wedges.setEditTriggers(QAbstractItemView.EditTrigger.AllEditTriggers)
self.ui.omega_wedges.setEditTriggers(
QAbstractItemView.EditTrigger.AllEditTriggers
)

def detector_selection(self, checked: bool) -> None:
self.state['all_detectors'] = checked
Expand Down
4 changes: 1 addition & 3 deletions hexrdgui/indexing/fit_grains_results_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,7 @@ def load_cmaps(self) -> None:

def update_cmap(self) -> None:
# Get the Colormap object from the name
self.cmap = matplotlib.colormaps.get_cmap(
self.ui.color_maps.currentText()
)
self.cmap = matplotlib.colormaps.get_cmap(self.ui.color_maps.currentText())
self.update_plot()

def reset_glyph_size(self, update_plot: bool = True) -> None:
Expand Down
21 changes: 17 additions & 4 deletions hexrdgui/indexing/fit_grains_tolerances_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

from typing import Any

from PySide6.QtCore import QAbstractTableModel, QModelIndex, QPersistentModelIndex, Qt, Signal
from PySide6.QtCore import (
QAbstractTableModel,
QModelIndex,
QPersistentModelIndex,
Qt,
Signal,
)
from PySide6.QtWidgets import QWidget


Expand All @@ -22,7 +28,9 @@ def __init__(self, parent: QWidget | None = None) -> None:

# Override methods:

def columnCount(self, parent: QModelIndex | QPersistentModelIndex = QModelIndex()) -> int:
def columnCount(
self, parent: QModelIndex | QPersistentModelIndex = QModelIndex()
) -> int:
return 3

def data(
Expand Down Expand Up @@ -72,13 +80,18 @@ def headerData(
orientation: Qt.Orientation,
role: int = Qt.ItemDataRole.DisplayRole,
) -> Any:
if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Horizontal:
if (
role == Qt.ItemDataRole.DisplayRole
and orientation == Qt.Orientation.Horizontal
):
headers = ['tth', 'eta', 'omega']
return headers[section]
# (else)
return super().headerData(section, orientation, role)

def rowCount(self, parent: QModelIndex | QPersistentModelIndex = QModelIndex()) -> int:
def rowCount(
self, parent: QModelIndex | QPersistentModelIndex = QModelIndex()
) -> int:
if parent.isValid():
return 0
return len(self.tth_tolerances)
Expand Down
5 changes: 4 additions & 1 deletion hexrdgui/indexing/grains_table_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ def headerData(
orientation: Qt.Orientation,
role: int = Qt.ItemDataRole.DisplayRole,
) -> Any:
if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Horizontal:
if (
role == Qt.ItemDataRole.DisplayRole
and orientation == Qt.Orientation.Horizontal
):
return self.headers[section]

return super().headerData(section, orientation, role)
Expand Down
4 changes: 3 additions & 1 deletion hexrdgui/input_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def getItem(
combo_box.setEditable(editable)
layout.addWidget(combo_box)

buttons = QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
buttons = (
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
)
button_box = QDialogButtonBox(buttons)
button_box.accepted.connect(dialog.accept)
button_box.rejected.connect(dialog.reject)
Expand Down
5 changes: 4 additions & 1 deletion hexrdgui/list_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ def clear_selection(self) -> None:

def select_row(self, i: int) -> None:
model_index = self.selection_model.model().index(i, 0)
command = QItemSelectionModel.SelectionFlag.Select | QItemSelectionModel.SelectionFlag.Rows
command = (
QItemSelectionModel.SelectionFlag.Select
| QItemSelectionModel.SelectionFlag.Rows
)
self.selection_model.select(model_index, command)

def selection_changed(self) -> None:
Expand Down
Loading
Loading