Skip to content

Conversation

bstaber
Copy link
Contributor

@bstaber bstaber commented Aug 28, 2025

This PR tries to simplify a bit the sample.py module by splitting responsabilities.

Summary:

  • A features.py module that contains SampleScalars and SampleMeshes
  • Those new objects handle the scalars and mesh mechanics
  • Several methods are removed from Sample

Checklist

  • Typing enforced
  • Documentation updated
  • Changelog updated
  • Tests and Example updates
  • Coverage should be 100%

@bstaber bstaber requested a review from a team as a code owner August 28, 2025 20:30
Copy link

gitnotebooks bot commented Aug 28, 2025

Review these changes at https://app.gitnotebooks.com/PLAID-lib/plaid/pull/171

@bstaber bstaber marked this pull request as draft August 28, 2025 20:30
Copy link

codecov bot commented Sep 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@bstaber bstaber changed the title ♻️ Refactoring Sample ♻️ Refactoring Sample/meshes/fields Sep 2, 2025
@bstaber bstaber changed the title ♻️ Refactoring Sample/meshes/fields ♻️ Refactoring Sample Sep 2, 2025
@bstaber bstaber marked this pull request as ready for review September 2, 2025 11:20
@bstaber
Copy link
Contributor Author

bstaber commented Sep 2, 2025

I think it's ready, you might want to check if I left all the methods the user needs in Sample.

I put SampleScalars in containers/scalars.py and SampleMeshes in containers/meshes.py.

@xroynard
Copy link
Contributor

xroynard commented Sep 3, 2025

maybe we should add an entry to the Changelog, to warn users that it is a major refactoring and that it might introduce problems

@xroynard
Copy link
Contributor

xroynard commented Sep 3, 2025

I put SampleScalars in containers/scalars.py and SampleMeshes in containers/meshes.py.

I think maybe scalars.py and meshes.py should be gathered in a sub-package of plaid.containers, for exemple plaid.containers.features

What do you think about that ?

@bstaber
Copy link
Contributor Author

bstaber commented Sep 3, 2025

@xroynard it's done let me know what you think about it

@bstaber bstaber changed the title ♻️ Refactoring Sample ♻️ Refactoring Sample by introducing features module Sep 3, 2025
@bstaber
Copy link
Contributor Author

bstaber commented Sep 3, 2025

Methods only in Sample

  • get_features_from_identifiers
  • get_all_features_identifiers_by_type
  • del_scalar
  • get_scalar_names
  • from_features_identifier
  • update_features_from_identifier
  • add_time_series
  • merge_features
  • serialize_model
  • del_time_series
  • set_default_base
  • get_feature_from_string_identifier
  • set_default_time
  • get_all_features_identifiers
  • get_time_series
  • add_scalar
  • set_default_zone_base
  • get_scalar
  • get_feature_from_identifier
  • del_all_fields
  • link_tree
  • get_time_series_names

Methods only in SampleMeshes

  • get_elements
  • get_zone_assignment
  • set_vertices
  • get_links
  • has_zone
  • add_tree
  • get_points
  • get_vertices
  • get_zone_type
  • get_topological_dim
  • get_nodal_tags
  • get_zone_names
  • get_base
  • get_all_mesh_times
  • del_zone
  • set_meshes
  • set_points
  • del_tree
  • get_base_assignment
  • get_time_assignment
  • get_zone
  • get_base_names
  • get_physical_dim
  • del_base
  • init_tree
  • has_base

@bstaber
Copy link
Contributor Author

bstaber commented Sep 3, 2025

Do you want to keep link_tree in Sample btw?

@casenave
Copy link
Member

casenave commented Sep 6, 2025

Do you want to keep link_tree in Sample btw?

we can remove, but the temporal dataset will not be working anymore, to discuss when to do it

Copy link
Member

@casenave casenave left a comment

Choose a reason for hiding this comment

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

We can discuss this in person

@casenave
Copy link
Member

casenave commented Sep 9, 2025

Do you want to keep link_tree in Sample btw?

We can put in in an experimental module and get rid of it in the main package.

@casenave
Copy link
Member

I think we can merge (after CHANGELOG is updated), and keep the experimental folder for another PR ? What is your take on this @bstaber @xroynard ?

@bstaber
Copy link
Contributor Author

bstaber commented Sep 12, 2025

Do you want me first to:

  • rename the underscores in _meshes and _scalars first ?
  • put a method add_mesh in Sample? I think all the methods related to meshes are in SampleMeshes right now (just checking)

@xroynard
Copy link
Contributor

Do you want me first to:

  • rename the underscores in _meshes and _scalars first ?
  • put a method add_mesh in Sample? I think all the methods related to meshes are in SampleMeshes right now (just checking)

there will already be a method add_mesh after #191 is merged

@casenave
Copy link
Member

Do you want me first to:

  • rename the underscores in _meshes and _scalars first ?
  • put a method add_mesh in Sample? I think all the methods related to meshes are in SampleMeshes right now (just checking)

we can rename in another PR if you want

@bstaber
Copy link
Contributor Author

bstaber commented Sep 12, 2025

Ok let's go then, I think I need a new approval

@casenave
Copy link
Member

Ok let's go then, I think I need a new approval

oops there still is the correction to the CHANGELOG, and some conflicts appear :-(

@bstaber
Copy link
Contributor Author

bstaber commented Sep 12, 2025

LGTR 🥵

@bstaber
Copy link
Contributor Author

bstaber commented Sep 12, 2025

image

Copy link
Member

@casenave casenave left a comment

Choose a reason for hiding this comment

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

Looks nice to me, thanks ! Just mentioning that the meshes arg may be renamed lie time_data or something else when/if we succeed in including a global in the CGNS tree to replace scalar and time_series.

@bstaber
Copy link
Contributor Author

bstaber commented Sep 12, 2025

FYI: tried to remove the underscores but it's not that simple. I have to change the way we use pydantic in Sample for that, I prefer to leave it for another PR

@bstaber bstaber merged commit c890cf4 into main Sep 16, 2025
27 checks passed
@bstaber bstaber deleted the refacto/sample-meshes branch September 16, 2025 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants