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
55 changes: 55 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: lint

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
lint:
runs-on: ubuntu-latest

defaults:
run:
shell: bash

steps:

- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: '3.11'

- name: Checkout HEXRD
uses: actions/checkout@v4
with:
repository: HEXRD/hexrd
path: hexrd

- name: Checkout HEXRDGUI
uses: actions/checkout@v4
with:
path: hexrdgui

- name: Install EGL (PySide6 needs it)
run: sudo apt-get update && sudo apt-get install -y libegl1-mesa-dev

- name: Install HEXRD
run: pip install .
working-directory: hexrd

- name: Install HEXRDGUI
run: pip install .
working-directory: hexrdgui

- name: Install linters
run: pip install mypy ruff types-PyYAML

- name: Run ruff format
run: ruff format --check hexrdgui/
working-directory: hexrdgui

- name: Run mypy
run: mypy hexrdgui/
working-directory: hexrdgui
15 changes: 8 additions & 7 deletions hexrdgui/about_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class AboutDialog(QObject):
def __init__(self, parent: QObject | None = None) -> None:
super().__init__(parent)
self.ui = UiLoader().load_file(
'about_dialog.ui', parent # type: ignore[arg-type]
'about_dialog.ui',
parent, # type: ignore[arg-type]
)

self._populate_hexrd_logo()
Expand Down Expand Up @@ -74,11 +75,11 @@ def _populate_versions(self) -> None:
tree = self.ui.information

packages = [
"HEXRDGUI",
"HEXRD",
"NumPy",
"SciPy",
"PySide6",
'HEXRDGUI',
'HEXRD',
'NumPy',
'SciPy',
'PySide6',
]

for package in packages:
Expand All @@ -87,5 +88,5 @@ def _populate_versions(self) -> None:
item.setText(1, version(package.lower()))

python = QTreeWidgetItem(tree)
python.setText(0, "Python")
python.setText(0, 'Python')
python.setText(1, sys.version)
1 change: 0 additions & 1 deletion hexrdgui/absorption_correction_options_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


class AbsorptionCorrectionOptionsDialog:

def __init__(self, parent: QWidget | None = None) -> None:
loader = UiLoader()
self.ui = loader.load_file('absorption_correction_options_dialog.ui', parent)
Expand Down
2 changes: 1 addition & 1 deletion hexrdgui/argument_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def check_positive_int(value: str) -> int:
"""Ensure the value is a positive int"""
error_msg = f"invalid positive int value: {value}"
error_msg = f'invalid positive int value: {value}'

try:
ivalue = int(value)
Expand Down
1 change: 0 additions & 1 deletion hexrdgui/async_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class AsyncRunner:

def __init__(self, parent: QWidget) -> None:
self.parent = parent

Expand Down
12 changes: 6 additions & 6 deletions hexrdgui/async_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class AsyncWorkerSignals(QObject):
'''
"""
Defines the signals available from a running worker thread.

Supported signals are:
Expand All @@ -27,7 +27,7 @@ class AsyncWorkerSignals(QObject):
progress
`int` indicating % progress

'''
"""

finished = Signal()
error = Signal(tuple)
Expand All @@ -36,7 +36,7 @@ class AsyncWorkerSignals(QObject):


class AsyncWorker(QRunnable):
'''
"""
AsyncWorker

Inherits from QRunnable to handler worker thread setup, signals and
Expand All @@ -49,7 +49,7 @@ class AsyncWorker(QRunnable):
:param args: Arguments to pass to the callback function
:param kwargs: Keywords to pass to the callback function

'''
"""

def __init__(self, fn: Callable[..., Any], *args: Any, **kwargs: Any) -> None:
super().__init__()
Expand All @@ -67,9 +67,9 @@ def __init__(self, fn: Callable[..., Any], *args: Any, **kwargs: Any) -> None:

@Slot()
def run(self) -> None:
'''
"""
Initialise the runner function with passed args, kwargs.
'''
"""

# Retrieve args/kwargs here; and fire processing using them
try:
Expand Down
1 change: 0 additions & 1 deletion hexrdgui/azimuthal_overlay_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class AzimuthalOverlayEditor:

def __init__(self, parent: QWidget | None = None) -> None:
loader = UiLoader()
self.ui = loader.load_file('azimuthal_overlay_editor.ui', parent)
Expand Down
1 change: 0 additions & 1 deletion hexrdgui/azimuthal_overlay_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@


class AzimuthalOverlayManager:

def __init__(self, parent: QWidget | None = None) -> None:
loader = UiLoader()
self.ui = loader.load_file('azimuthal_overlay_manager.ui', parent)
Expand Down
1 change: 0 additions & 1 deletion hexrdgui/azimuthal_overlay_style_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class AzimuthalOverlayStylePicker(QObject):

def __init__(self, overlay: Any, parent: QObject | None = None) -> None:
super().__init__(parent)

Expand Down
1 change: 0 additions & 1 deletion hexrdgui/beam_marker_style_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


class BeamMarkerStyleEditor:

def __init__(self, parent: QWidget | None = None) -> None:
loader = UiLoader()
self.ui = loader.load_file('beam_marker_style_editor.ui', parent)
Expand Down
2 changes: 1 addition & 1 deletion hexrdgui/blit_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, canvas: Any) -> None:
self.artists: dict[str, Any] = {}

# grab the background on every draw
self.cid = canvas.mpl_connect("draw_event", self.on_draw)
self.cid = canvas.mpl_connect('draw_event', self.on_draw)

def disconnect(self) -> None:
self.remove_artists()
Expand Down
1 change: 0 additions & 1 deletion hexrdgui/brightness_contrast_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@


class BrightnessContrastEditor(QObject):

edited = Signal(float, float)

reset = Signal()
Expand Down
2 changes: 0 additions & 2 deletions hexrdgui/cal_tree_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@


class CalTreeItemModel(BaseTreeItemModel):

def __init__(self, parent: QWidget | None = None) -> None:
super().__init__(parent)
self.root_item = TreeItem(['key', 'value'])
Expand Down Expand Up @@ -238,7 +237,6 @@ def set_value(self, key: Any, cur_config: Any, cur_tree_item: Any) -> None:


class CalTreeView(QTreeView):

def model(self) -> CalTreeItemModel:
return super().model() # type: ignore[return-value]

Expand Down
6 changes: 1 addition & 5 deletions hexrdgui/calibration/auto/powder_calibration_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


class PowderCalibrationDialog:

def __init__(self, material: Material, parent: QWidget | None = None) -> None:
loader = UiLoader()
self.ui = loader.load_file('powder_calibration_dialog.ui', parent)
Expand All @@ -38,10 +37,7 @@ def setup_combo_boxes(self) -> None:
def update_gui(self) -> None:
if self.tth_tol is None:
default = 0.125
msg = (
'Powder overlay width is required.\n\n'
f'Setting to default: {default}°'
)
msg = f'Powder overlay width is required.\n\nSetting to default: {default}°'
QMessageBox.warning(self.ui.parent(), 'HEXRD', msg)
self.tth_tol = default

Expand Down
2 changes: 0 additions & 2 deletions hexrdgui/calibration/auto/powder_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@


class PowderRunner(QObject):

calibration_finished = Signal()

def __init__(self, parent: QWidget | None = None) -> None:
Expand Down Expand Up @@ -195,7 +194,6 @@ def save_picks_to_overlay(self) -> None:


class CalibrationCallbacks(MaterialCalibrationDialogCallbacks):

@property
def data_xys(self) -> dict:
ret: dict[str, Any] = {}
Expand Down
18 changes: 9 additions & 9 deletions hexrdgui/calibration/calibration_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@


class CalibrationDialog(QObject):

draw_picks_toggled = Signal(bool)
show_picks_from_all_xray_sources_toggled = Signal(bool)

Expand Down Expand Up @@ -73,7 +72,8 @@ def __init__(

loader = UiLoader()
self.ui = loader.load_file(
'calibration_dialog.ui', parent # type: ignore[arg-type]
'calibration_dialog.ui',
parent, # type: ignore[arg-type]
)

self.ui.setWindowFlags(self.ui.windowFlags() | Qt.WindowType.Tool)
Expand Down Expand Up @@ -217,15 +217,15 @@ def initialize_advanced_options(self) -> None:
@property
def default_advanced_options(self) -> dict[str, Any]:
return {
"ftol": 1e-8,
"xtol": 1e-8,
"gtol": 1e-8,
"verbose": 2,
"max_nfev": 1000,
'ftol': 1e-8,
'xtol': 1e-8,
'gtol': 1e-8,
'verbose': 2,
'max_nfev': 1000,
# Skip x_scale until we find a way to present it in the GUI
# "x_scale": "jac",
"method": "trf",
"jac": "3-point",
'method': 'trf',
'jac': '3-point',
}

@property
Expand Down
2 changes: 0 additions & 2 deletions hexrdgui/calibration/calibration_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@


class CalibrationRunner(QObject):

calibration_finished = Signal()

def __init__(
Expand Down Expand Up @@ -996,7 +995,6 @@ def on_rejected() -> None:


class CalibrationCallbacks(MaterialCalibrationDialogCallbacks):

def __init__(self, overlays: list, *args: Any, **kwargs: Any) -> None:
self.overlays = overlays

Expand Down
1 change: 0 additions & 1 deletion hexrdgui/calibration/cartesian_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def get_xray_propagation_sign(instr: HEDMInstrument) -> Any:


class InstrumentViewer:

def __init__(self) -> None:
self.type = ViewType.cartesian
self.instr = create_hedm_instrument()
Expand Down
1 change: 0 additions & 1 deletion hexrdgui/calibration/display_plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@


class DisplayPlane:

def __init__(
self,
tilt: np.ndarray = tilt_DFTL,
Expand Down
14 changes: 6 additions & 8 deletions hexrdgui/calibration/hedm/calibration_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@


class HEDMCalibrationDialog(CalibrationDialog):

apply_refinement_selections_needed = Signal()

def __init__(self, *args: Any, **kwargs: Any) -> None:
Expand Down Expand Up @@ -247,7 +246,6 @@ def validate_parameters(self) -> None:


class HEDMCalibrationCallbacks(MaterialCalibrationDialogCallbacks):

dialog: HEDMCalibrationDialog # type: ignore[assignment]

def __init__(
Expand Down Expand Up @@ -455,9 +453,9 @@ def run_calibration(self, **extra_kwargs: Any) -> Any:
ims = next(iter(ims_dict.values())) # grab first member
delta_ome = ims.metadata['omega'][:, 1] - ims.metadata['omega'][:, 0]
# In the spirit of Joel, I'm leaving his comment here...
assert (
np.max(np.abs(np.diff(delta_ome))) < cnst.sqrt_epsf
), "something funky going one with your omegas"
assert np.max(np.abs(np.diff(delta_ome))) < cnst.sqrt_epsf, (
'something funky going one with your omegas'
)
delta_ome = delta_ome[0] # any one member will do

# refit tolerances
Expand Down Expand Up @@ -510,9 +508,9 @@ def run_calibration(self, **extra_kwargs: Any) -> Any:
)

print(
"INFO: Will keep %d of %d input reflections "
'INFO: Will keep %d of %d input reflections '
% (sum(idx_1), sum(idx_0[det_key][ig]))
+ "on panel %s for re-fit" % det_key
+ 'on panel %s for re-fit' % det_key
)

idx_new = np.zeros_like(idx_0[det_key][ig], dtype=bool)
Expand Down Expand Up @@ -667,6 +665,6 @@ def parse_spots_data(
REFINEMENT_OPTIONS = {
'fix_det_y': 'Fix origin based on current sample/detector position',
'fix_grain_centroid': 'Reset origin to grain centroid position',
'fix_grain_y': 'Reset Y axis origin to grain\'s Y position',
'fix_grain_y': "Reset Y axis origin to grain's Y position",
'custom': 'Custom refinement parameters',
}
Loading
Loading