-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add mesh_stats checks and field_operations features #51
base: main
Are you sure you want to change the base?
Conversation
…om/GEOS-DEV/geosPythonPackages into origin/benedicto/followUpMeshStats
…rrays available in the source data + better error handling
from dataclasses import dataclass | ||
from geos.mesh.doctor.checks.vtk_utils import ( VtkOutput, get_points_coords_from_vtk, get_cell_centers_array, | ||
get_vtm_filepath_from_pvd, get_vtu_filepaths_from_vtm, | ||
get_all_array_names, read_mesh, write_mesh ) |
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.
I would move the "local" imports at the end
class Options: | ||
support: str # choice between 'cell' and 'point' to operate on fields | ||
source: str # file from where the data is collected | ||
operations: list[ tuple[ str ] ] # [ ( function0, new_name0 ), ... ] |
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.
From the comment, it seems like we expect exactly 2 str in the tuple. Would something like list[ tuple[ str, str ] ]
work?
|
||
Returns: | ||
array: [ distance0, distance1, ..., distanceN ] with N being the number of support elements. | ||
""" |
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.
Looks like a great opportunity to use your support_construction
defined at L30.
Returns: | ||
array: Array of size N being the number of support elements. | ||
""" | ||
if support == __SUPPORT_CHOICES[ 0 ]: |
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.
It's tempting to have a seperate function that would return the number of elements, especially if the support_choices
list is intended to grow in the future.
That would avoid changing the code everywhere it is repeated, like L209.
|
||
|
||
def get_random_field( mesh: vtkUnstructuredGrid, support: str ) -> array: | ||
f"""For a specific support type {__SUPPORT_CHOICES}, an array with samples from a uniform distribution over [0, 1). |
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.
In the doc string, "returns an array..."
for i in range( result.number_cell_types ): | ||
logging.info( f"\t{result.cell_types[ i ]}\t\t({result.cell_type_counts[ i ]} cells)" ) |
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.
For readability and as you did L80, we could do:
for i in range( result.number_cell_types ): | |
logging.info( f"\t{result.cell_types[ i ]}\t\t({result.cell_type_counts[ i ]} cells)" ) | |
for cell_type, type_count in zip(result.number_cell_types, result.cell_type_counts ): | |
logging.info( f"\t{cell_type}\t\t({type_count} cells)" ) |
for field_name, validity_range in data.items(): | ||
is_valid: bool = validity_range[ 0 ] | ||
min_max: tuple[ float ] = validity_range[ 1 ] |
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.
for field_name, validity_range in data.items(): | |
is_valid: bool = validity_range[ 0 ] | |
min_max: tuple[ float ] = validity_range[ 1 ] | |
for field_name, (is_valid, min_max) in data.items(): |
if options.write_stats: | ||
if is_valid_to_write_folder( options.output_folder ): |
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.
if options.write_stats: | |
if is_valid_to_write_folder( options.output_folder ): | |
if options.write_stats and is_valid_to_write_folder( options.output_folder ): |
for i, sub_grid in enumerate( sub_grids ): | ||
for name, value in sub_grids_values[ i ].items(): |
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.
for i, sub_grid in enumerate( sub_grids ): | |
for name, value in sub_grids_values[ i ].items(): | |
for sub_grid, sub_grid_value in zip(sub_grids, sub_grids_values): | |
for name, value in sub_grid_value.items(): |
} | ||
|
||
|
||
def get_vtu_filepaths( options: Options ) -> tuple[ str ]: |
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.
At some point, could maybe be moved to the vtk utils ?
Closes #50
Followed the previous work on PR #19 and closes #19.
Two features added: