From 413b15dc3640860ed399231ba79a991b1f2ba20a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 22:19:08 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/snapred/backend/service/SousChef.py | 15 ++++----------- .../resources/ultralite/create_ultralite_data.py | 1 + .../recipe/test_EffectiveInstrumentRecipe.py | 3 ++- .../recipe/test_PreprocessReductionRecipe.py | 5 ++--- tests/unit/backend/recipe/test_ReductionRecipe.py | 9 +++++---- tests/unit/backend/service/test_SousChef.py | 8 +++----- tests/unit/ui/workflow/test_DiffCalWorkflow.py | 1 + 7 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/snapred/backend/service/SousChef.py b/src/snapred/backend/service/SousChef.py index 522e8a8ce..804b49aab 100644 --- a/src/snapred/backend/service/SousChef.py +++ b/src/snapred/backend/service/SousChef.py @@ -104,7 +104,7 @@ def prepPixelGroup( ingredients.useLiteMode, groupingSchema, ingredients.calibrantSamplePath, - pixelMask + pixelMask, ) if key not in self._pixelGroupCache: focusGroup = self.prepFocusGroup(ingredients) @@ -116,10 +116,7 @@ def prepPixelGroup( self.groceryClerk.name("groupingWorkspace").fromRun(ingredients.runNumber).grouping( focusGroup.name ).useLiteMode(ingredients.useLiteMode).add() - groceries = self.groceryService.fetchGroceryDict( - self.groceryClerk.buildDict(), - maskWorkspace=pixelMask - ) + groceries = self.groceryService.fetchGroceryDict(self.groceryClerk.buildDict(), maskWorkspace=pixelMask) data = PixelGroupingParametersCalculationRecipe().executeRecipe(pixelIngredients, groceries) self._pixelGroupCache[key] = PixelGroup( @@ -131,9 +128,7 @@ def prepPixelGroup( return deepcopy(self._pixelGroupCache[key]) def prepManyPixelGroups( - self, - ingredients: FarmFreshIngredients, - pixelMask: Optional[WorkspaceName] = None + self, ingredients: FarmFreshIngredients, pixelMask: Optional[WorkspaceName] = None ) -> List[PixelGroup]: pixelGroups = [] ingredients_ = ingredients.model_copy() @@ -267,9 +262,7 @@ def _pullNormalizationRecordFFI( return ingredients, smoothingParameter, calibrantSamplePath def prepReductionIngredients( - self, - ingredients: FarmFreshIngredients, - combinedPixelMask: Optional[WorkspaceName] = None + self, ingredients: FarmFreshIngredients, combinedPixelMask: Optional[WorkspaceName] = None ) -> ReductionIngredients: ingredients_ = ingredients.model_copy() # some of the reduction ingredients MUST match those used in the calibration/normalization processes diff --git a/src/snapred/resources/ultralite/create_ultralite_data.py b/src/snapred/resources/ultralite/create_ultralite_data.py index 21f427938..b48a9f74c 100644 --- a/src/snapred/resources/ultralite/create_ultralite_data.py +++ b/src/snapred/resources/ultralite/create_ultralite_data.py @@ -1,6 +1,7 @@ # import mantid algorithms, numpy and matplotlib from mantid.simpleapi import * + from snapred.backend.dao.ingredients.GroceryListItem import GroceryListItem from snapred.backend.data.DataFactoryService import DataFactoryService from snapred.backend.data.GroceryService import GroceryService diff --git a/tests/unit/backend/recipe/test_EffectiveInstrumentRecipe.py b/tests/unit/backend/recipe/test_EffectiveInstrumentRecipe.py index fe31079b4..db6f22178 100644 --- a/tests/unit/backend/recipe/test_EffectiveInstrumentRecipe.py +++ b/tests/unit/backend/recipe/test_EffectiveInstrumentRecipe.py @@ -2,13 +2,14 @@ import numpy as np import pytest +from util.SculleryBoy import SculleryBoy + from snapred.backend.dao.ingredients import EffectiveInstrumentIngredients as Ingredients from snapred.backend.dao.state.FocusGroup import FocusGroup from snapred.backend.dao.state.PixelGroup import PixelGroup from snapred.backend.recipe.algorithm.Utensils import Utensils from snapred.backend.recipe.EffectiveInstrumentRecipe import EffectiveInstrumentRecipe from snapred.meta.Config import Resource -from util.SculleryBoy import SculleryBoy class TestEffectiveInstrumentRecipe: diff --git a/tests/unit/backend/recipe/test_PreprocessReductionRecipe.py b/tests/unit/backend/recipe/test_PreprocessReductionRecipe.py index 4e5386c31..ddd9e4e7f 100644 --- a/tests/unit/backend/recipe/test_PreprocessReductionRecipe.py +++ b/tests/unit/backend/recipe/test_PreprocessReductionRecipe.py @@ -6,15 +6,14 @@ LoadInstrument, mtd, ) +from util.helpers import createCompatibleMask +from util.SculleryBoy import SculleryBoy from snapred.backend.dao.ingredients import PreprocessReductionIngredients as Ingredients from snapred.backend.recipe.algorithm.Utensils import Utensils from snapred.backend.recipe.PreprocessReductionRecipe import PreprocessReductionRecipe from snapred.meta.Config import Resource -from util.helpers import createCompatibleMask -from util.SculleryBoy import SculleryBoy - class PreprocessReductionRecipeTest(unittest.TestCase): fakeInstrumentFilePath = Resource.getPath("inputs/testInstrument/fakeSNAP_Definition.xml") diff --git a/tests/unit/backend/recipe/test_ReductionRecipe.py b/tests/unit/backend/recipe/test_ReductionRecipe.py index d011b3d3f..65ce78d4f 100644 --- a/tests/unit/backend/recipe/test_ReductionRecipe.py +++ b/tests/unit/backend/recipe/test_ReductionRecipe.py @@ -3,6 +3,8 @@ import pytest from mantid.simpleapi import CreateSingleValuedWorkspace, mtd +from util.Config_helpers import Config_override +from util.SculleryBoy import SculleryBoy from snapred.backend.dao.ingredients import ReductionIngredients from snapred.backend.recipe.ReductionRecipe import ( @@ -15,8 +17,6 @@ ) from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceNameGenerator as wng -from util.SculleryBoy import SculleryBoy -from util.Config_helpers import Config_override class ReductionRecipeTest(TestCase): sculleryBoy = SculleryBoy() @@ -478,7 +478,6 @@ def test_execute(self, mockMtd): assert recipe._deleteWorkspace.call_count == len(recipe._prepGroupingWorkspaces.return_value) assert result["outputs"][0] == "sample_grouped" - @mock.patch("mantid.simpleapi.mtd", create=True) def test_execute_useEffectiveInstrument(self, mockMtd): with Config_override("reduction.output.useEffectiveInstrument", True): @@ -491,7 +490,9 @@ def test_execute_useEffectiveInstrument(self, mockMtd): mockGroupWorkspace.readY.return_value = [0] * 10 mockMaskworkspace.readY.return_value = [0] * 10 - mockMtd.__getitem__.side_effect = lambda ws_name: mockMaskworkspace if ws_name == "mask" else mockGroupWorkspace + mockMtd.__getitem__.side_effect = ( + lambda ws_name: mockMaskworkspace if ws_name == "mask" else mockGroupWorkspace + ) recipe = ReductionRecipe() recipe.mantidSnapper = mockMantidSnapper diff --git a/tests/unit/backend/service/test_SousChef.py b/tests/unit/backend/service/test_SousChef.py index 6d29d5a21..83c05d9d1 100644 --- a/tests/unit/backend/service/test_SousChef.py +++ b/tests/unit/backend/service/test_SousChef.py @@ -180,7 +180,7 @@ def test_prepPixelGroup_nocache( self.ingredients.useLiteMode, self.ingredients.focusGroup.name, self.ingredients.calibrantSamplePath, - None + None, ) # ensure there is no cached value @@ -213,14 +213,13 @@ def test_prepPixelGroup_nocache( @mock.patch(thisService + "PixelGroupingParametersCalculationRecipe") def test_prepPixelGroup_cache(self, PixelGroupingParametersCalculationRecipe): - # ensure the cache is prepared key = ( self.ingredients.runNumber, self.ingredients.useLiteMode, self.ingredients.focusGroup.name, self.ingredients.calibrantSamplePath, - self.pixelMask + self.pixelMask, ) self.instance._pixelGroupCache[key] = mock.sentinel.pixel @@ -230,14 +229,13 @@ def test_prepPixelGroup_cache(self, PixelGroupingParametersCalculationRecipe): assert res == self.instance._pixelGroupCache[key] def test_prepPixelGroup_cache_not_altered(self): - # ensure the cache is prepared key = ( self.ingredients.runNumber, self.ingredients.useLiteMode, self.ingredients.focusGroup.name, self.ingredients.calibrantSamplePath, - None + None, ) self.instance._pixelGroupCache[key] = PixelGroup.construct(timeOfFlight={"minimum": 0}) diff --git a/tests/unit/ui/workflow/test_DiffCalWorkflow.py b/tests/unit/ui/workflow/test_DiffCalWorkflow.py index 7af33de47..5915ff458 100644 --- a/tests/unit/ui/workflow/test_DiffCalWorkflow.py +++ b/tests/unit/ui/workflow/test_DiffCalWorkflow.py @@ -8,6 +8,7 @@ mtd, ) from qtpy.QtWidgets import QMessageBox + from snapred.meta.mantid.FitPeaksOutput import FIT_PEAK_DIAG_SUFFIX, FitOutputEnum from snapred.meta.pointer import create_pointer from snapred.ui.workflow.DiffCalWorkflow import DiffCalWorkflow