Skip to content

Conversation

@RomainBaville
Copy link
Contributor

This pr aims to update the filter to not use try/except scheme. This scheme must be used in the upper function (main or ParaView plugin). The function applyFilter of the filter must raise exception if needed.
The tests and the ParaView plugin are updated to.

This pr follows the pr #178

onPoints=self.onPoints,
logger=self.logger ):
raise ValueError(
f"Something got wrong with the creation of the attribute { self.newAttributeName }." )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"Something got wrong with the creation of the attribute { self.newAttributeName }." )
f"Something went wrong with the creation of the attribute { self.newAttributeName }." )

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do a ctlr shift F to find and change them all please ? :) they're everywhere

self.onPoints )
if len( validIndexes ) == 0:
if len( self.dictRegionValues ) == 0:
self.logger.warning( "No region indexes entered." )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.logger.warning( "No region indexes entered." )
self.logger.warning( "No region index entered." )

self.onPoints )
if len( validIndexes ) == 0:
if len( self.dictRegionValues ) == 0:
self.logger.warning( "No region indexes entered." )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.logger.warning( "No region indexes entered." )
self.logger.warning( "No region index entered." )

onPoints=self.onPoints,
logger=self.logger ):
raise ValueError(
f"Something got wrong with the creation of the attribute { self.newAttributeName }." )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"Something got wrong with the creation of the attribute { self.newAttributeName }." )
f"Something went wrong with the creation of the attribute { self.newAttributeName }." )

onPoints=self.onPoints,
logger=self.logger ):
raise ValueError(
f"Something got wrong with the creation of the attribute { self.newAttributeName }." )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"Something got wrong with the creation of the attribute { self.newAttributeName }." )
f"Something went wrong with the creation of the attribute { self.newAttributeName }." )

Comment on lines 744 to 750
if not createAttribute( self.output,
array,
attributeName,
componentNames=componentNames,
onPoints=onPoints,
logger=self.logger ):
raise ValueError( f"Something got wrong during the creation of the attribute { attributeName }." )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment about raise and createAttribute

Comment on lines 166 to 172
if not createConstantAttribute( volumeMesh, [ blockIndex ],
PostProcessingOutputsEnum.BLOCK_INDEX.attributeName,
onPoints=False,
logger=self.logger ):
raise ValueError(
f"Something got wrong during the creation of the attribute { PostProcessingOutputsEnum.BLOCK_INDEX.attributeName }."
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Comment on lines 378 to +391
if not createAttribute(
self.outputMesh, scuAttribute, SCUAttributeName, (), self.attributeOnPoints, logger=self.logger ):
self.logger.error( f"Failed to create attribute {SCUAttributeName}." )
raise
raise ValueError( f"Failed to create attribute {SCUAttributeName}." )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Comment on lines 36 to 61
@pytest.mark.parametrize( "meshFromName, meshToName, attributeNames, onPoints, error", [
( "dataset", "emptydataset", {}, False, "ValueError" ),
( "dataset", "emptydataset", { "Fault" }, False, "AttributeError" ),
( "dataset", "dataset", { "GLOBAL_IDS_CELLS" }, False, "AttributeError" ),
( "multiblock", "emptymultiblock", { "FAULT" }, False, "AttributeError" ),
( "dataset", "emptyFracture", { "FAULT" }, False, "ValueError" ),
] )
def test_AttributeMappingRaises(
dataSetTest: Any,
meshFromName: str,
meshToName: str,
attributeNames: set[ str ],
onPoints: bool,
error: str,
) -> None:
"""Test the fails of the filter."""
meshFrom: Union[ vtkDataSet, vtkMultiBlockDataSet ] = dataSetTest( meshFromName )
meshTo: Union[ vtkDataSet, vtkMultiBlockDataSet ] = dataSetTest( meshToName )
attributeMappingFilter: AttributeMapping = AttributeMapping( meshFrom, meshTo, attributeNames, onPoints )

if error == "AttributeError":
with pytest.raises( AttributeError ):
attributeMappingFilter.applyFilter()
elif error == "ValueError":
with pytest.raises( ValueError ):
attributeMappingFilter.applyFilter()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you split the test at least in two (e.g. AttributeError/ ValueError) and comment briefly what is tested (raise due to xxxx ).

Comment on lines 125 to 131
createConstantAttributePerRegionFilter.applyFilter()
elif error == "AttributeError":
with pytest.raises( AttributeError ):
createConstantAttributePerRegionFilter.applyFilter()
elif error == "ValueError":
with pytest.raises( ValueError ):
createConstantAttributePerRegionFilter.applyFilter()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also split this test please (not fail/fail type 1/ fail type 2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants