Skip to content

refactor: Standardize meshdata attribute names#227

Open
anas-ibrahem wants to merge 4 commits into
noaa-ocs-modeling:mainfrom
anas-ibrahem:Standardize-MeshData-names
Open

refactor: Standardize meshdata attribute names#227
anas-ibrahem wants to merge 4 commits into
noaa-ocs-modeling:mainfrom
anas-ibrahem:Standardize-MeshData-names

Conversation

@anas-ibrahem

Copy link
Copy Markdown
Contributor

Summary

This PR standardizes mesh attribute names across the codebase.
coords, tria, quad, values are now the canonical API on all mesh classes, which fixes AttributeError issues when passing EuclideanMesh2D objects to utility functions.

Resolves #226

Changes

  • base.pycoords is now the main property; coord is kept as a deprecated alias.
  • mesh.pytria, quad, and values replace triangles, quads, and value. Old names remain as deprecated aliases. Helpers updated.
  • collector.py — Switched to tria, coords, values.
  • combine_geom.py — Switched to coords in CRS reprojection.
  • test_mesh.py — Updated .value to .values.

Testing & Results

python -m pytest tests/ -v
# result: 175 passed, 8 skipped

#verify deprecated names warn and new names are silent with simple assertions
python -c "
import warnings, numpy as np
from ocsmesh.internal import MeshData
from ocsmesh.mesh.mesh import EuclideanMesh2D

md = MeshData(coords=np.array([[0,0],[1,0],[0.5,1.0]]), tria=np.array([[0,1,2]]))
m = EuclideanMesh2D(md)

with warnings.catch_warnings(record=True) as w:
    warnings.simplefilter('always')
    _ = m.coord; _ = m.triangles; _ = m.quads; _ = m.value
    assert len(w) == 4 and all(issubclass(x.category, DeprecationWarning) for x in w)
    print('PASS: all 4 old names warn correctly')

with warnings.catch_warnings(record=True) as w:
    warnings.simplefilter('always')
    _ = m.coords; _ = m.tria; _ = m.quad; _ = m.values
    assert len(w) == 0
    print('PASS: new canonical names produce no warnings')
"

Note*
I investigated the 8 skipped tests. They are pre-existing, intentional skips unrelated to our changes ,all 8 are conditionally skipped because I am running the test suite on Windows.

  • test_avg_filter_nomask
  • test_avg_filter_masked_nanfill
  • test_avg_filter_masked_nonnanfill
  • test_add_patch
  • test_hfunraster_initial_value_logic
  • test_execution_mode_property
  • test_work_dir_cleanup
  • test_serial_vs_parallel_equivalence

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.

Inconsistent Attribute Naming on EuclideanMesh2D

1 participant