Skip to content

Phase 2: Foundation & Code Quality#33

Merged
shaia merged 12 commits intomasterfrom
foundation/phase2-code-quality
Mar 7, 2026
Merged

Phase 2: Foundation & Code Quality#33
shaia merged 12 commits intomasterfrom
foundation/phase2-code-quality

Conversation

@shaia
Copy link
Copy Markdown
Owner

@shaia shaia commented Mar 6, 2026

Summary

  • Add pytest configuration with markers and filterwarnings
  • Replace duplicated version string with importlib.metadata (single source in pyproject.toml)
  • Add VTKData field shape validation, NaN/inf warnings, and __repr__
  • Add field name aliases (FIELD_ALIASES, CANONICAL_NAMES) so data["pressure"] resolves to data["p"]
  • Add __contains__ and has_field() to VTKData for alias-aware membership tests
  • 35 new VTK reader tests + 5 end-to-end integration tests (526 total, all passing)

Test plan

  • pytest tests/ --ignore=tests/interactive -v — 526 passed
  • ruff check . — clean
  • ruff format --check . — clean (pre-existing example formatting excluded)
  • python -c "from cfd_viz import __version__; print(__version__)" — prints 0.1.0

shaia added 3 commits March 6, 2026 20:16
…ion and field aliases

Phase 2 (Foundation & Code Quality) source changes:

- Add [tool.pytest.ini_options] with testpaths, markers, and filterwarnings
- Replace hardcoded __version__ with importlib.metadata lookup
- Add VTKData field shape validation (ValueError on mismatch)
- Add NaN/inf warnings and __repr__ to VTKData
- Add FIELD_ALIASES and CANONICAL_NAMES for field name normalization
- Add __contains__ and has_field() to VTKData for alias-aware lookup
- Normalize SCALARS field names at VTK read time (e.g. "pressure" -> "p")
35 tests for VTK reader covering construction, validation, field aliases,
STRUCTURED_POINTS/RECTILINEAR_GRID parsing, malformed files, and the
read_vtk_velocity convenience function.

5 integration tests verifying the full pipeline: VTK read -> compute
derived fields -> plot, cfd-python conversion, field alias resolution,
version accessibility, and VTKData repr.
@shaia shaia requested a review from Copilot March 6, 2026 18:18
@shaia shaia self-assigned this Mar 6, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR completes “Phase 2” foundation work by tightening package/test configuration, improving VTK reader robustness and ergonomics (aliases/validation), and adding substantial automated test coverage.

Changes:

  • Adds pytest configuration (testpaths, markers, warning filters) in pyproject.toml.
  • Enhances VTKData/VTK reader with field validation, NaN/inf warnings, alias-aware access, and canonical name normalization at read-time.
  • Adds a large set of VTK reader unit tests plus end-to-end integration tests, and updates the roadmap status.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pyproject.toml Adds pytest ini options (markers, filterwarnings).
cfd_viz/common/vtk_reader.py Adds canonical naming/aliases, VTKData validation/warnings, repr, alias-aware accessors, and scalar name normalization.
cfd_viz/common/__init__.py Re-exports FIELD_ALIASES.
cfd_viz/__init__.py Switches __version__ to importlib.metadata.version() with fallback.
tests/common/test_vtk_reader.py Adds comprehensive unit tests for the VTK reader and alias behavior.
tests/common/__init__.py Adds package marker for tests.common.
tests/test_integration.py Adds end-to-end integration tests for reading/conversion/plotting/version/repr.
ROADMAP.md Marks Phase 2 as complete and summarizes delivered work.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

shaia added 5 commits March 7, 2026 06:53
VTK sample files are gitignored (*.vtk) so they don't exist in CI.
Tests that depend on real VTK files now skip gracefully instead of failing.
…LARS parser

The isalpha() check treated valid float tokens like "nan" and "inf" as
VTK keywords, prematurely terminating scalar field parsing. Check against
known VTK section headers instead.
…ject.toml

Replace hard-coded "0.1.0" fallback with "0+unknown" so it cannot
silently drift from the canonical version in pyproject.toml.
Tests that previously required gitignored VTK sample files now generate
their own test data via _write_structured_points in tmp_path, so they
work in CI without needing real data files.
…VTK fixtures

Integration tests now generate their own VTK data in tmp_path instead
of depending on gitignored sample files, ensuring they work in CI.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

shaia added 2 commits March 7, 2026 08:44
Renamed test_canonical_names_not_in_aliases_as_values to
test_canonical_names_not_aliased_to_themselves since it asserts
canonical names are not present as keys in FIELD_ALIASES.
np.isnan/np.isinf raise TypeError on integer arrays. Skip the check
for non-floating dtypes since they cannot contain NaN or inf.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

shaia added 2 commits March 7, 2026 12:30
…ormalization

Eliminates duplicate pressure->p mapping by using FIELD_ALIASES as the
single source of truth for both read-time normalization and lookup-time
aliasing.
Add validate=True parameter to VTKData constructor so callers can
skip the O(N) per-field nan/inf scans for large grids when not needed.
@shaia shaia merged commit aa84a2b into master Mar 7, 2026
1 check passed
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.

2 participants