From 658aa16a35189cca3ec74a6346cc6e0495a4c590 Mon Sep 17 00:00:00 2001 From: lachlangrose Date: Mon, 9 Nov 2026 15:05:21 +1030 Subject: [PATCH] style: format 12 files with black 26.10.1 so the linter passes --- .../feature_details_panel/_base.py | 4 +++- .../geological_model_tab.py | 7 ++----- .../layer_selection_table.py | 15 ++++++++++----- .../model_definition/stratigraphic_layers.py | 3 ++- .../gui/modelling/modelling_widget.py | 9 +++++---- loopstructural/gui/modelling/steps/pages.py | 18 ++++++++++++------ .../gui/modelling/steps/section_stack.py | 4 +--- .../stratigraphic_column.py | 1 - .../visualisation/object_properties_widget.py | 1 + loopstructural/main/constraints.py | 5 ++++- tests/qgis/test_fault_topology_button.py | 4 +--- tests/qgis/test_manual_foliations.py | 8 ++------ 12 files changed, 43 insertions(+), 36 deletions(-) diff --git a/loopstructural/gui/modelling/geological_model_tab/feature_details_panel/_base.py b/loopstructural/gui/modelling/geological_model_tab/feature_details_panel/_base.py index 8c269a7..3fb0965 100644 --- a/loopstructural/gui/modelling/geological_model_tab/feature_details_panel/_base.py +++ b/loopstructural/gui/modelling/geological_model_tab/feature_details_panel/_base.py @@ -394,7 +394,9 @@ def _toggle_detached(self): if reply != QMessageBox.StandardButton.Yes: return manager.attach_feature(name) - push_info("Feature", f"'{name}' follows the stratigraphic column again. Rebuild the model.") + push_info( + "Feature", f"'{name}' follows the stratigraphic column again. Rebuild the model." + ) elif manager.detach_feature(name): push_info("Feature", f"'{name}' is detached. Its data is a fixed copy.") else: diff --git a/loopstructural/gui/modelling/geological_model_tab/geological_model_tab.py b/loopstructural/gui/modelling/geological_model_tab/geological_model_tab.py index 9d8e6eb..f07fcbe 100644 --- a/loopstructural/gui/modelling/geological_model_tab/geological_model_tab.py +++ b/loopstructural/gui/modelling/geological_model_tab/geological_model_tab.py @@ -74,8 +74,7 @@ def _build_status_icon(color: str, *, filled: bool, mark: str = None) -> QIcon: 'initialized': "Model status: initialized (not solved)", 'solved': "Model status: solved", 'stale': ( - "Model status: faults, stratigraphic column or input data changed — " - "rebuild the model" + "Model status: faults, stratigraphic column or input data changed — " "rebuild the model" ), } @@ -524,9 +523,7 @@ def _confirm_bounding_box_contains_data(self): ) return reply == QMessageBox.StandardButton.Yes - def _run_model_task( - self, target, *, title, initial_label, cancellable=True, on_success=None - ): + def _run_model_task(self, target, *, title, initial_label, cancellable=True, on_success=None): """Run `target(progress_callback)` on a background QThread with a non-modal progress dialog, so the rest of QGIS stays usable. Both Initialize Model and Solve Model share this: they disable each other diff --git a/loopstructural/gui/modelling/geological_model_tab/layer_selection_table.py b/loopstructural/gui/modelling/geological_model_tab/layer_selection_table.py index 6cba001..d2f251c 100644 --- a/loopstructural/gui/modelling/geological_model_tab/layer_selection_table.py +++ b/loopstructural/gui/modelling/geological_model_tab/layer_selection_table.py @@ -535,9 +535,7 @@ def _setup_common_fields(self, layout): self.weight_spin.setDecimals(3) self.weight_spin.setRange(0.001, 1000.0) self.weight_spin.setSingleStep(0.1) - self.weight_spin.setValue( - self.existing_data.get('weight', constraints.DEFAULT_WEIGHT) - ) + self.weight_spin.setValue(self.existing_data.get('weight', constraints.DEFAULT_WEIGHT)) self.weight_spin.setToolTip("How much the constraint counts in the interpolation.") form.addRow("Weight:", self.weight_spin) @@ -545,7 +543,12 @@ def _setup_common_fields(self, layout): for source in constraints.Z_SOURCES: self.z_source_combo.addItem(constraints.Z_LABELS[source], source) self.z_source_combo.setCurrentIndex( - max(self.z_source_combo.findData(self.existing_data.get('z_source', constraints.Z_LAYER)), 0) + max( + self.z_source_combo.findData( + self.existing_data.get('z_source', constraints.Z_LAYER) + ), + 0, + ) ) self.z_source_combo.setToolTip( "Where the Z of the points comes from: the geometry of the layer, the DEM " @@ -561,7 +564,9 @@ def _setup_common_fields(self, layout): layout.addLayout(form) def update_z_value_state(): - self.z_value_spin.setEnabled(self.z_source_combo.currentData() == constraints.Z_CONSTANT) + self.z_value_spin.setEnabled( + self.z_source_combo.currentData() == constraints.Z_CONSTANT + ) self.z_source_combo.currentIndexChanged.connect(update_z_value_state) update_z_value_state() diff --git a/loopstructural/gui/modelling/model_definition/stratigraphic_layers.py b/loopstructural/gui/modelling/model_definition/stratigraphic_layers.py index bc52e8e..7f14579 100644 --- a/loopstructural/gui/modelling/model_definition/stratigraphic_layers.py +++ b/loopstructural/gui/modelling/model_definition/stratigraphic_layers.py @@ -89,7 +89,8 @@ def _apply_contacts_source(self, source): else: configure_layer_combo( self.basalContactsLayer, - QgsMapLayerProxyModel.Filter.LineLayer | QgsMapLayerProxyModel.Filter.PointLayer, + QgsMapLayerProxyModel.Filter.LineLayer + | QgsMapLayerProxyModel.Filter.PointLayer, allow_empty=True, ) self.groupBox_basalContacts.setTitle("Basal contacts") diff --git a/loopstructural/gui/modelling/modelling_widget.py b/loopstructural/gui/modelling/modelling_widget.py index 12df79f..30a9d59 100644 --- a/loopstructural/gui/modelling/modelling_widget.py +++ b/loopstructural/gui/modelling/modelling_widget.py @@ -148,9 +148,7 @@ def _visible_indices(self): def _neighbour(self, direction, index=None): """Return the index of the next visible step, or ``index`` if there is none.""" index = self.current_index if index is None else index - candidates = [ - i for i in self._visible_indices() if (i - index) * direction > 0 - ] + candidates = [i for i in self._visible_indices() if (i - index) * direction > 0] if not candidates: return index return min(candidates, key=lambda i: abs(i - index)) @@ -162,7 +160,10 @@ def _apply_workflow_mode(self, mode): for page in self.pages: self.step_bar.set_step_visible(page.key, page.key in visible) self.data_step.set_workflow_mode(mode) - if self.stack.currentIndex() >= 0 and self.pages[self.stack.currentIndex()].key not in visible: + if ( + self.stack.currentIndex() >= 0 + and self.pages[self.stack.currentIndex()].key not in visible + ): self.go_to(self.stack.currentIndex()) else: self.refresh_status() diff --git a/loopstructural/gui/modelling/steps/pages.py b/loopstructural/gui/modelling/steps/pages.py index a3aced7..467bf86 100644 --- a/loopstructural/gui/modelling/steps/pages.py +++ b/loopstructural/gui/modelling/steps/pages.py @@ -261,7 +261,9 @@ def __init__(self, parent=None, **kwargs): self.fault_layers.faultTraceLayer.layerChanged.connect(self.update_topology_button) self.fault_layers.faultNameField.fieldChanged.connect(self.update_topology_button) if self.data_manager is not None: - self.data_manager.layer_roles.attach(lambda _role, _value: self.update_topology_button()) + self.data_manager.layer_roles.attach( + lambda _role, _value: self.update_topology_button() + ) self.update_topology_button() self.adjacency = FaultAdjacencyTab(self, data_manager=self.data_manager) @@ -274,7 +276,11 @@ def _fault_traces(self): def update_topology_button(self, *_args): """Enable the button when the fault layer and the name field are set.""" traces = self._fault_traces() - layer = self.data_manager.get_layer_role(layer_roles.FAULT_TRACES) if self.data_manager else None + layer = ( + self.data_manager.get_layer_role(layer_roles.FAULT_TRACES) + if self.data_manager + else None + ) if layer is None or not traces.get('fault_name_field'): self.topology_button.setEnabled(False) self.topology_button.setToolTip( @@ -289,11 +295,11 @@ def update_topology_button(self, *_args): def _calculate_topology(self): self.message_bar.clearWidgets() try: - result = calculate_from_data_manager( - self.data_manager, self.tolerance_spin_box.value() - ) + result = calculate_from_data_manager(self.data_manager, self.tolerance_spin_box.value()) except FaultTopologyError as error: - self.message_bar.pushMessage("Fault topology", str(error), level=Qgis.MessageLevel.Critical) + self.message_bar.pushMessage( + "Fault topology", str(error), level=Qgis.MessageLevel.Critical + ) return text, warn = result_message(result) self.message_bar.pushMessage( diff --git a/loopstructural/gui/modelling/steps/section_stack.py b/loopstructural/gui/modelling/steps/section_stack.py index aae3b67..87f663b 100644 --- a/loopstructural/gui/modelling/steps/section_stack.py +++ b/loopstructural/gui/modelling/steps/section_stack.py @@ -61,9 +61,7 @@ def _save_state(self): self._settings_key, {key: self.is_open(key) for key in self._sections} ) - def add_section( - self, widget, key, title, *, summary=None, collapsed=False, index=None - ): + def add_section(self, widget, key, title, *, summary=None, collapsed=False, index=None): """Add a section and return its group box. ``widget`` is the content, or a `QgsCollapsibleGroupBox` that the stack diff --git a/loopstructural/gui/modelling/stratigraphic_column/stratigraphic_column.py b/loopstructural/gui/modelling/stratigraphic_column/stratigraphic_column.py index 051f8b0..e973aa3 100644 --- a/loopstructural/gui/modelling/stratigraphic_column/stratigraphic_column.py +++ b/loopstructural/gui/modelling/stratigraphic_column/stratigraphic_column.py @@ -32,7 +32,6 @@ from .init_from_field_dialog import InitFromLayerFieldDialog from .stratigraphic_unit import StratigraphicUnitWidget - # The values of the "Style by" combo STYLE_COLOUR = 'colour' STYLE_ORDER = 'order' diff --git a/loopstructural/gui/visualisation/object_properties_widget.py b/loopstructural/gui/visualisation/object_properties_widget.py index a331ea2..c5ecc83 100644 --- a/loopstructural/gui/visualisation/object_properties_widget.py +++ b/loopstructural/gui/visualisation/object_properties_widget.py @@ -31,6 +31,7 @@ render_histogram, ) + class ObjectPropertiesWidget(QWidget): """The properties of the selected viewer object. diff --git a/loopstructural/main/constraints.py b/loopstructural/main/constraints.py index 5ea6e6b..0ec8c5d 100644 --- a/loopstructural/main/constraints.py +++ b/loopstructural/main/constraints.py @@ -69,6 +69,7 @@ def has_weight(layer_type): """Return True if a row of the type `layer_type` has a weight.""" return layer_type not in UNWEIGHTED_TYPES + # The keys of a row that name a field of the layer, for each type. A row # without these keys is not complete. REQUIRED_FIELDS = { @@ -85,7 +86,9 @@ def has_weight(layer_type): def missing_fields(layer_data): """Return the keys that a row needs and does not have.""" - return [key for key in REQUIRED_FIELDS.get(layer_data.get('type'), ()) if not layer_data.get(key)] + return [ + key for key in REQUIRED_FIELDS.get(layer_data.get('type'), ()) if not layer_data.get(key) + ] def solver_for(layer_type): diff --git a/tests/qgis/test_fault_topology_button.py b/tests/qgis/test_fault_topology_button.py index b1bc2a5..c56cafa 100644 --- a/tests/qgis/test_fault_topology_button.py +++ b/tests/qgis/test_fault_topology_button.py @@ -14,9 +14,7 @@ def page(): project = QgsProject.instance() model_manager = GeologicalModelManager() - data_manager = ModellingDataManager( - project=project, mapCanvas=Mock(), logger=Mock() - ) + data_manager = ModellingDataManager(project=project, mapCanvas=Mock(), logger=Mock()) data_manager.set_model_manager(model_manager) return FaultsStep(None, data_manager=data_manager, model_manager=model_manager) diff --git a/tests/qgis/test_manual_foliations.py b/tests/qgis/test_manual_foliations.py index 9343cdd..3e30253 100644 --- a/tests/qgis/test_manual_foliations.py +++ b/tests/qgis/test_manual_foliations.py @@ -179,9 +179,7 @@ def test_a_pairwise_inequality_needs_the_admm_solver(self, manager, monkeypatch) assert kwargs == {'solver': 'admm'} assert 'pair_id' in data - def test_with_the_native_solver_a_pairwise_inequality_needs_no_admm( - self, manager, monkeypatch - ): + def test_with_the_native_solver_a_pairwise_inequality_needs_no_admm(self, manager, monkeypatch): monkeypatch.setattr(solver_choice, 'use_native', lambda setting: True) df = _points(order=lambda p: 1 if p.x < 50 else 2) layer = {'type': 'Pairwise Inequality', 'pair_field': 'order', 'df': df} @@ -199,9 +197,7 @@ def test_a_feature_from_value_and_normal_layers_solves_without_a_column(self, ma 'vector_z_field': 'nz', 'df': _points(nx=lambda p: 1.0, ny=lambda p: 0.0, nz=lambda p: 0.0), } - manager.add_foliation( - 's1', {'values': values, 'normals': normals}, use_z_coordinate=True - ) + manager.add_foliation('s1', {'values': values, 'normals': normals}, use_z_coordinate=True) manager.update_all_features(notify_observers=False) result = manager.model['s1'].evaluate_value(np.array([[50.0, 50.0, 0.0]])) assert not np.any(np.isnan(result))