Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 20, 2025
1 parent 1264ece commit 00b3779
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 30 deletions.
3 changes: 1 addition & 2 deletions src/snapred/backend/dao/state/RunNumber.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ def validateRunNumber(cls, value):
f"Run number {value} does not meet the minimum required value or does not have cached data available."
)
raise ValueError(
f"Run number {value} is below the minimum value or data does not exist."
"Please enter a valid run number."
f"Run number {value} is below the minimum value or data does not exist.Please enter a valid run number."
)

return value
Expand Down
2 changes: 1 addition & 1 deletion src/snapred/backend/error/StateValidationException.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, exception: Exception):
doesFileExist, hasWritePermission = self._checkFileAndPermissions(filePath)

if filePath and doesFileExist and hasWritePermission:
self.message = f"The following error occurred:{exceptionStr}\n\n" "Please contact your IS or CIS."
self.message = f"The following error occurred:{exceptionStr}\n\nPlease contact your IS or CIS."
elif filePath and doesFileExist:
self.message = f"You do not have write permissions: {filePath}"
elif filePath:
Expand Down
2 changes: 1 addition & 1 deletion src/snapred/backend/service/CalibrationService.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def pixelCalibration(self, request: SimpleDiffCalRequest) -> PixelDiffCalServing
res.result = False
raise Exception(
(
f"WARNING: More than {threshold*100}% of pixels failed calibration. Please check your input "
f"WARNING: More than {threshold * 100}% of pixels failed calibration. Please check your input "
"data. If input data has poor statistics, you may get better results by disabling Cross "
"Correlation. You can also improve statistics by activating Lite mode if this is not "
"already activated."
Expand Down
3 changes: 1 addition & 2 deletions src/snapred/backend/service/ReductionService.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ def validateReduction(self, request: ReductionRequest):
# Case: No calibration but normalization exists
continueFlags |= ContinueWarning.Type.MISSING_DIFFRACTION_CALIBRATION
message = (
"Warning: diffraction calibration is missing."
"If you continue, default instrument geometry will be used."
"Warning: diffraction calibration is missing.If you continue, default instrument geometry will be used."
)
elif calibrationExists and not normalizationExists:
# Case: Calibration exists but normalization is missing
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/backend/dao/test_CalibrantSample.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def test_setCalibrantSample(self):
ref = f"""
<type name="userShape">
<{self.geo.shape.lower()} id="sample-shape">
<centre-of-bottom-base x="0" y="{-round(self.geo.height*0.005,3)}" z="0"/>
<centre-of-bottom-base x="0" y="{-round(self.geo.height * 0.005, 3)}" z="0"/>
<axis x="0" y="1" z="0"/>
<height val="{round(self.geo.height*0.01,3)}"/>
<radius val="{round(self.geo.radius*0.01,3)}"/>
<height val="{round(self.geo.height * 0.01, 3)}"/>
<radius val="{round(self.geo.radius * 0.01, 3)}"/>
</{self.geo.shape.lower()}>
</type>
"""
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/backend/dao/test_Geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ def test_settableInMantidJSON(self):
ref = f"""
<type name="userShape">
<{self.cylinder.shape.lower()} id="sample-shape">
<centre-of-bottom-base x="0" y="{-self.cylinder.height*0.005}" z="0"/>
<centre-of-bottom-base x="0" y="{-self.cylinder.height * 0.005}" z="0"/>
<axis x="0" y="1" z="0"/>
<height val="{self.cylinder.height*0.01}"/>
<radius val="{self.cylinder.radius*0.01}"/>
<height val="{self.cylinder.height * 0.01}"/>
<radius val="{self.cylinder.radius * 0.01}"/>
</{self.cylinder.shape.lower()}>
</type>
"""
Expand All @@ -111,7 +111,7 @@ def test_settableInMantidJSON(self):
<type name="userShape">
<{self.sphere.shape.lower()} id="sphere">
<center x="0" y="0" z="0"/>
<radius val="{self.sphere.radius*0.01}"/>
<radius val="{self.sphere.radius * 0.01}"/>
</{self.sphere.shape.lower()}>
</type>
"""
Expand All @@ -138,10 +138,10 @@ def test_settableInMantidDict(self):
ref = f"""
<type name="userShape">
<{self.cylinder.shape.lower()} id="sample-shape">
<centre-of-bottom-base x="0" y="{-self.cylinder.height*0.005}" z="0"/>
<centre-of-bottom-base x="0" y="{-self.cylinder.height * 0.005}" z="0"/>
<axis x="0" y="1" z="0"/>
<height val="{self.cylinder.height*0.01}"/>
<radius val="{self.cylinder.radius*0.01}"/>
<height val="{self.cylinder.height * 0.01}"/>
<radius val="{self.cylinder.radius * 0.01}"/>
</{self.cylinder.shape.lower()}>
</type>
"""
Expand All @@ -159,7 +159,7 @@ def test_settableInMantidDict(self):
<type name="userShape">
<{self.sphere.shape.lower()} id="sphere">
<center x="0" y="0" z="0"/>
<radius val="{self.sphere.radius*0.01}"/>
<radius val="{self.sphere.radius * 0.01}"/>
</{self.sphere.shape.lower()}>
</type>
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def makeFakeNeutronData(self, rawWsName: str, focusWSname: str) -> None:
OutputWorkspace=rawWsName,
# WorkspaceType="Histogram",
Function="User Defined",
UserDefinedFunction=f"name=Gaussian,Height=10,PeakCentre={midpoint},Sigma={midpoint/10}",
UserDefinedFunction=f"name=Gaussian,Height=10,PeakCentre={midpoint},Sigma={midpoint / 10}",
Xmin=overallDMin,
Xmax=overallDMax,
BinWidth=abs(dBin),
Expand Down Expand Up @@ -202,7 +202,7 @@ def test_failedValidation_inputGroupingIdsMismatch(self):
OutputWorkspace=self.fakeRawData,
# WorkspaceType="Histogram",
Function="User Defined",
UserDefinedFunction=f"name=Gaussian,Height=10,PeakCentre={midpoint},Sigma={midpoint/10}",
UserDefinedFunction=f"name=Gaussian,Height=10,PeakCentre={midpoint},Sigma={midpoint / 10}",
Xmin=overallDMin,
Xmax=overallDMax,
BinWidth=abs(dBin),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def test_chop_ingredients(self):
assert groupID in algo.groupIDs, f"Group ID {groupID} not found in maskRegions"

expected_group_ids = [peakList.groupID for peakList in peaks]
assert (
algo.groupIDs == expected_group_ids
), f"Group IDs in workspace and peak list do not match: {algo.groupIDs} vs {expected_group_ids}"
assert algo.groupIDs == expected_group_ids, (
f"Group IDs in workspace and peak list do not match: {algo.groupIDs} vs {expected_group_ids}"
)

def test_incorrect_group_ids(self):
peaks = [
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/backend/recipe/test_ReductionRecipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,14 +711,14 @@ def test_execute_with_fully_masked_group(self, mockMtd):
recipe.logger().warning.assert_any_call(expected_warning_message_group2)

# Ensure the warning was called twice (once per group)
assert (
recipe.logger().warning.call_count == 2
), "Expected warning to be logged twice for the fully masked groups."
assert recipe.logger().warning.call_count == 2, (
"Expected warning to be logged twice for the fully masked groups."
)

# Ensure no algorithms were applied for the fully masked groups
assert (
recipe._applyRecipe.call_count == 2
), "Expected _applyRecipe to not be called for the fully masked groups."
assert recipe._applyRecipe.call_count == 2, (
"Expected _applyRecipe to not be called for the fully masked groups."
)

# Check the output result contains the mask workspace
assert result["outputs"][0] == "mask", "Expected the mask workspace to be included in the outputs."
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/meta/test_Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ def test_key_substitution():


def test_multi_level_substitution():
assert Config["test.data.home.write"] == f'~/{Config["test.config.home"]}/data/{Config["test.config.name"]}'
assert Config["test.data.home.read"] == f'{Config["test.config.home"]}/data/{Config["test.config.name"]}'
assert Config["test.data.home.write"] == f"~/{Config['test.config.home']}/data/{Config['test.config.name']}"
assert Config["test.data.home.read"] == f"{Config['test.config.home']}/data/{Config['test.config.name']}"


def test_fromMantidLoggingLevel():
Expand Down

0 comments on commit 00b3779

Please sign in to comment.