feat(med): preserve mesh name, description and units across read/write round-trip#12
Open
fznoussi wants to merge 2 commits into
Open
feat(med): preserve mesh name, description and units across read/write round-trip#12fznoussi wants to merge 2 commits into
fznoussi wants to merge 2 commits into
Conversation
…e round-trip Previously, the mesh name was always hardcoded to 'mesh' on write, and the description/units attributes (DES, UNT, UNI) were always reset to their default values. This meant that any MED file that went through a read→write cycle would lose its original metadata. Changes: - read(): extract DES, UNT, UNI attributes from the HDF5 mesh group and store them on the Mesh object as .description, .unit_time, .unit_coords - read(): store the original mesh name as .mesh_name on the Mesh object - write(): use getattr(mesh, 'mesh_name', 'mesh') so the original name is reused if present, falling back to 'mesh' for meshes not coming from a MED file - write(): use getattr() for description/unit_time/unit_coords with safe fallbacks so non-MED meshes still write valid files Why: any tool (e.g. Salome, Code_Aster) that relies on the mesh name or units being preserved will now get correct output after a round-trip.
Add tests for the DES/UNT/UNI attributes and the mesh name introduced by feat/preserve-mesh-metadata. - defaults: a bare mesh round-trips to the documented fallbacks (mesh_name=mesh, default description, empty units), which exercises the getattr() default branches of write() that were previously untested. - custom values: parametrized read->write->read loop for description, unit_time and unit_coords, asserting the value is both reconstructed on read and written back (not overwritten by a default). - mesh name: a custom name survives a full round-trip and the default mesh does not reappear; uses write() to build a consistent file instead of renaming HDF5 groups. - whitespace: read() trims padded string fields (justifies the .strip() cleanup, relevant for files written by Salome).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, the mesh name was always hardcoded to 'mesh' on write, and the description/units attributes (DES, UNT, UNI) were always reset to their default values. This meant that any MED file that went through a read→write cycle would lose its original metadata.
Changes:
Why: any tool (e.g. Salome, Code_Aster) that relies on the mesh name or units being preserved will now get correct output after a round-trip.