Skip to content

feat: improve and update of geos-mesh utils functions #109

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

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

RomainBaville
Copy link

@RomainBaville RomainBaville commented Jun 27, 2025

This PR updates the utils functions of geos-mesh:

  • Functions are added to arrayHelper.py
  • Functions in arrayModifiers are updated to be more global and consistent
    • VTK data type and value type are checked to be coherent
    • No more hard coded variable
  • Tests in test_arrayModifiers.py are updated to check more unit case

close #108

Copy link
Contributor

@paloma-martinez paloma-martinez left a comment

Choose a reason for hiding this comment

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

Thanks for the work on the logger !

It looks good to me, I only made a few suggestions on wording

Comment on lines +49 to +50
nb_component (int): Nb of components.
nb_elements (int): Nb of elements.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
nb_component (int): Nb of components.
nb_elements (int): Nb of elements.
nb_component (int): Number of components.
nb_elements (int): Number of elements.

Defaults to False.
value (any, optional): value to fill in the partial atribute.
Defaults to nan. For int vtk array, default value is automatically set to -1.
value (Any, optional): Filling value. It is better to use numpy scalar type for the values.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
value (Any, optional): Filling value. It is better to use numpy scalar type for the values.
value (Any, optional): Filling value. It is recommended to use numpy scalar type for the values.

attributeName (str): name of the attribute.
componentNames (tuple[str,...], optional): name of the components for vectorial attributes. If one component, give an empty tuple.
object (vtkDataObject): Object (vtkMultiBlockDataSet, vtkDataSet) where to create the attribute.
listValues (list[Any]): List of values of the attribute for each components. It is better to use numpy scalar type for the values.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
listValues (list[Any]): List of values of the attribute for each components. It is better to use numpy scalar type for the values.
listValues (list[Any]): List of values of the attribute for each components. It is recommended to use numpy scalar type for the values.

) -> bool:
"""Create an attribute with a constant value everywhere if absent.
"""Create a new attribute with a constant value per component on every blocks of the multiBlockDataSet.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"""Create a new attribute with a constant value per component on every blocks of the multiBlockDataSet.
"""Create a new attribute with a constant value per component on every block of the multiBlockDataSet.

attributeName (str): name of the attribute.
componentNames (tuple[str,...], optional): name of the components for vectorial attributes. If one component, give an empty tuple.
multiBlockDataSet (vtkMultiBlockDataSet | vtkCompositeDataSet): MultiBlockDataSet where to create the attribute.
listValues (list[Any]): List of values of the attribute for each components. It is better to use numpy scalar type for the values.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
listValues (list[Any]): List of values of the attribute for each components. It is better to use numpy scalar type for the values.
listValues (list[Any]): List of values of the attribute for each components. It is recommended to use numpy scalar type for the values.

logger.warning(
f"During the creation of the constant attribute { attributeName }, values will be converted from { valueType } to { npType }."
)
logger.warning( "To avoid any issue with the conversion use directly numpy scalar type for the values" )
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
logger.warning( "To avoid any issue with the conversion use directly numpy scalar type for the values" )
logger.warning( "To avoid any issue with the conversion, please use directly numpy scalar type for the values" )

logger.warning( "To avoid any issue with the conversion use directly numpy scalar type for the values" )
valueType = npType

# Check the coherency between the given value type and the vtk array type if it exist.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Check the coherency between the given value type and the vtk array type if it exist.
# Check the consistency between the given value type and the vtk array type if it exists.

vtkDataType (Union[int, None], optional): Vtk data type of the attribute to create.
Defaults to None, the vtk data type is given by the type of the array.

Warning with int8, uint8 and int64 type, the vtk data type corresponding are multiples. By default:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Warning with int8, uint8 and int64 type, the vtk data type corresponding are multiples. By default:
Warning with int8, uint8 and int64 type, the corresponding vtk data type are multiples. By default:

vtkDataType (Union[int, None], optional): Vtk data type of the attribute to create.
Defaults to None, the vtk data type is given by the type of the values.

Warning with int8, uint8 and int64 type of value, the vtk data type corresponding are multiples. By default:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Warning with int8, uint8 and int64 type of value, the vtk data type corresponding are multiples. By default:
Warning with int8, uint8 and int64 type of value, the corresponding vtk data type are multiples. By default:

vtkDataType (Union[int, None], optional): Vtk data type of the attribute to create.
Defaults to None, the vtk data type is given by the type of the values.

Warning with int8, uint8 and int64 type of value, the vtk data type corresponding are multiples. By default:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Warning with int8, uint8 and int64 type of value, the vtk data type corresponding are multiples. By default:
Warning with int8, uint8 and int64 type of value, the corresponding vtk data type are multiples. By default:

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.

Improve geos-mesh utils functions
2 participants