-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: refactor vtk filter without try/except scheme #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: RomainBaville/refactor/AddAndCheckLoggerForFilterAndPlugins
Are you sure you want to change the base?
Conversation
| onPoints=self.onPoints, | ||
| logger=self.logger ): | ||
| raise ValueError( | ||
| f"Something got wrong with the creation of the attribute { self.newAttributeName }." ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| f"Something got wrong with the creation of the attribute { self.newAttributeName }." ) | |
| f"Something went wrong with the creation of the attribute { self.newAttributeName }." ) |
There was a problem hiding this comment.
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." ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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." ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 }." ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 }." ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| f"Something got wrong with the creation of the attribute { self.newAttributeName }." ) | |
| f"Something went wrong with the creation of the attribute { self.newAttributeName }." ) |
| 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 }." ) |
There was a problem hiding this comment.
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
| 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 }." | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
| 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}." ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
| @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() |
There was a problem hiding this comment.
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 ).
| createConstantAttributePerRegionFilter.applyFilter() | ||
| elif error == "AttributeError": | ||
| with pytest.raises( AttributeError ): | ||
| createConstantAttributePerRegionFilter.applyFilter() | ||
| elif error == "ValueError": | ||
| with pytest.raises( ValueError ): | ||
| createConstantAttributePerRegionFilter.applyFilter() |
There was a problem hiding this comment.
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)
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