From 04d0a3eb4316666e3e3a423e1fa63c160e0b7de1 Mon Sep 17 00:00:00 2001 From: Romain Baville Date: Wed, 17 Sep 2025 13:17:23 +0200 Subject: [PATCH 1/2] Control warning messages in fillAllPartialArray --- .../src/geos/mesh/utils/arrayModifiers.py | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/geos-mesh/src/geos/mesh/utils/arrayModifiers.py b/geos-mesh/src/geos/mesh/utils/arrayModifiers.py index e14ac2d94..ebc033c20 100644 --- a/geos-mesh/src/geos/mesh/utils/arrayModifiers.py +++ b/geos-mesh/src/geos/mesh/utils/arrayModifiers.py @@ -60,6 +60,7 @@ def fillPartialAttributes( onPoints: bool = False, listValues: Union[ list[ Any ], None ] = None, logger: Union[ Logger, None ] = None, + fillAll: bool = False, ) -> bool: """Fill input partial attribute of multiBlockDataSet with a constant value per component. @@ -75,6 +76,8 @@ def fillPartialAttributes( nan for float VTK arrays. logger (Union[Logger, None], optional): A logger to manage the output messages. Defaults to None, an internal logger is used. + fillAll (bool, optional): True if fillPartialAttributes is used by fillAllPartialAttributes, else False. + Defaults to False. Returns: bool: True if the attribute was correctly created and filled, False if not. @@ -105,32 +108,29 @@ def fillPartialAttributes( # Set the default value depending of the type of the attribute to fill if listValues is None: defaultValue: Any - logger.warning( f"The attribute { attributeName } is filled with the default value for each component." ) + mess: str = f"The attribute { attributeName } is filled with the default value for each component.\n" # Default value for float types is nan. if vtkDataType in ( VTK_FLOAT, VTK_DOUBLE ): defaultValue = valueType( np.nan ) - logger.warning( - f"{ attributeName } vtk data type is { vtkDataType } corresponding to { defaultValue.dtype } numpy type, default value is automatically set to nan." - ) + mess = mess + f"{ attributeName } vtk data type is { vtkDataType } corresponding to { defaultValue.dtype } numpy type, default value is automatically set to nan." # Default value for int types is -1. elif vtkDataType in ( VTK_CHAR, VTK_SIGNED_CHAR, VTK_SHORT, VTK_LONG, VTK_INT, VTK_LONG_LONG, VTK_ID_TYPE ): defaultValue = valueType( -1 ) - logger.warning( - f"{ attributeName } vtk data type is { vtkDataType } corresponding to { defaultValue.dtype } numpy type, default value is automatically set to -1." - ) + mess = mess + f"{ attributeName } vtk data type is { vtkDataType } corresponding to { defaultValue.dtype } numpy type, default value is automatically set to -1." # Default value for uint types is 0. elif vtkDataType in ( VTK_BIT, VTK_UNSIGNED_CHAR, VTK_UNSIGNED_SHORT, VTK_UNSIGNED_LONG, VTK_UNSIGNED_INT, VTK_UNSIGNED_LONG_LONG ): defaultValue = valueType( 0 ) - logger.warning( - f"{ attributeName } vtk data type is { vtkDataType } corresponding to { defaultValue.dtype } numpy type, default value is automatically set to 0." - ) + mess = mess + f"{ attributeName } vtk data type is { vtkDataType } corresponding to { defaultValue.dtype } numpy type, default value is automatically set to 0." else: logger.error( f"The type of the attribute { attributeName } is not compatible with the function." ) return False listValues = [ defaultValue ] * nbComponents + if not fillAll: + logger.warning( mess ) + else: if len( listValues ) != nbComponents: return False @@ -158,7 +158,12 @@ def fillAllPartialAttributes( multiBlockDataSet: Union[ vtkMultiBlockDataSet, vtkCompositeDataSet, vtkDataObject ], logger: Union[ Logger, None ] = None, ) -> bool: - """Fill all partial attributes of a multiBlockDataSet with the default value. All components of each attributes are filled with the same value. Depending of the type of the attribute, the default value is different 0, -1 and nan for respectively uint, int and float vtk type. + """Fill all partial attributes of a multiBlockDataSet with the default value. + + All components of each attributes are filled with the same value. Depending of the type of the attribute's data, the default value is different: + 0 for uint data, + -1 for int data, + nan float data, Args: multiBlockDataSet (vtkMultiBlockDataSet | vtkCompositeDataSet | vtkDataObject): MultiBlockDataSet where to fill attributes. @@ -171,13 +176,15 @@ def fillAllPartialAttributes( # Check if an external logger is given. if logger is None: logger = getLogger( "fillAllPartialAttributes", True ) + + logger.warning( "The filling value for the attributes is depending of the type of attribute's data:\n0 for uint data,\n-1 for int data,\nnan for float data.") # Parse all partial attributes, onPoints and onCells to fill them. for onPoints in [ True, False ]: infoAttributes: dict[ str, int ] = getAttributesWithNumberOfComponents( multiBlockDataSet, onPoints ) for attributeName in infoAttributes: if not isAttributeGlobal( multiBlockDataSet, attributeName, onPoints ) and \ - not fillPartialAttributes( multiBlockDataSet, attributeName, onPoints=onPoints, logger=logger ): + not fillPartialAttributes( multiBlockDataSet, attributeName, onPoints=onPoints, logger=logger, fillAll=True ): return False return True From f3ad3f4952a32f5a390c9d190a495183b2f200e8 Mon Sep 17 00:00:00 2001 From: Romain Baville Date: Wed, 17 Sep 2025 13:21:33 +0200 Subject: [PATCH 2/2] fix for the ci --- geos-mesh/src/geos/mesh/utils/arrayModifiers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/geos-mesh/src/geos/mesh/utils/arrayModifiers.py b/geos-mesh/src/geos/mesh/utils/arrayModifiers.py index ebc033c20..2724acda7 100644 --- a/geos-mesh/src/geos/mesh/utils/arrayModifiers.py +++ b/geos-mesh/src/geos/mesh/utils/arrayModifiers.py @@ -176,8 +176,10 @@ def fillAllPartialAttributes( # Check if an external logger is given. if logger is None: logger = getLogger( "fillAllPartialAttributes", True ) - - logger.warning( "The filling value for the attributes is depending of the type of attribute's data:\n0 for uint data,\n-1 for int data,\nnan for float data.") + + logger.warning( + "The filling value for the attributes is depending of the type of attribute's data:\n0 for uint data,\n-1 for int data,\nnan for float data." + ) # Parse all partial attributes, onPoints and onCells to fill them. for onPoints in [ True, False ]: