Skip to content

fix: #1069 - [Phase E3-F4-P2] Create GasSpecies facade over GasData with deprecation warnings and tests#1081

Merged
Gorkowski merged 3 commits intouncscode:mainfrom
Gorkowski:issue-1069-adw-029a4449
Feb 17, 2026
Merged

fix: #1069 - [Phase E3-F4-P2] Create GasSpecies facade over GasData with deprecation warnings and tests#1081
Gorkowski merged 3 commits intouncscode:mainfrom
Gorkowski:issue-1069-adw-029a4449

Conversation

@Gorkowski
Copy link
Collaborator

Target Branch: main

Fixes #1069 | Workflow: 029a4449

Summary

Refactors GasSpecies into a facade over GasData while preserving the legacy API and behavior. Constructor now emits a deprecation warning guiding users to the new data container, with filters to keep CI running under -Werror. Conversion helpers were updated to round-trip through GasData without emitting warnings, and a migration guide plus focused tests were added to validate delegation and internal normalization.

What Changed

New Components

  • docs/migration/particle-data.md - Migration guide mapping facades (GasSpecies, ParticleRepresentation) to data containers with warning-handling guidance.
  • particula/gas/tests/species_facade_test.py - Facade-level tests for deprecation warnings, delegation, data updates, and multi-species handling.
  • particula/gas/tests/species_private_test.py - Unit tests for normalization/private helpers (modes, clamping, append invariants).

Modified Components

  • particula/gas/species.py - Rebuilt as a GasData-backed facade with normalization helpers, mode tracking for scalar/array returns, from_data constructor, data property, and atomic append/set operations; constructor now warns with migration link.
  • particula/gas/gas_data.py - from_species/to_species adjusted to work with the facade, enforce uniform partitioning, select box index safely, and avoid deprecation warnings by using GasSpecies.from_data.
  • particula/gas/tests/gas_data_test.py - Added coverage for warning-free conversion, partitioning validation, and box selection.
  • conftest.py & particula/conftest.py - Targeted GasSpecies deprecation warning filters to keep existing tests passing under -Werror while allowing explicit warning assertions.
  • pyproject.toml - Registered GasSpecies deprecation filter for pytest defaults.

Tests Added/Updated

  • particula/gas/tests/species_facade_test.py
  • particula/gas/tests/species_private_test.py
  • particula/gas/tests/gas_data_test.py (new cases)

How It Works

GasSpecies now normalizes inputs to arrays, builds GasData, and tracks single-species return modes so legacy scalar/1D behaviors stay intact. Vapor-pressure strategies remain on the facade; data accessors delegate to GasData, and setters rebuild the data container with validation/clamping. Conversion helpers wrap/unwrap GasData via from_data to avoid emitting deprecation warnings and enforce uniform partitioning.

┌────────────────┐   behavior   ┌────────────────────┐
│ Vapor strategy │────────────▶│   GasSpecies facade │
└────────────────┘              │  (warns, delegates) │
                                ▼
                         ┌──────────────┐
                         │   GasData    │
                         │ (boxes x n)  │
                         └──────────────┘

Implementation Notes

  • Deprecation warning issued only in __init__; from_data path is warning-free for conversions/tests.
  • Warning filters added at root and package conftests and pytest config to keep existing suites green under -Werror; facade tests assert warnings explicitly.
  • Append/set operations validate box and partitioning consistency and rebuild GasData atomically to avoid partial state.

Testing

  • pytest (workflow “Run Tests”) including new facade and conversion tests.

Refactor GasSpecies into a facade that stores GasData while
preserving legacy attribute access and vapor-pressure behavior.
Emit deprecation warnings on construction and provide from_data
for warning-free conversions, with to_species updated accordingly.

Add facade tests, private helper coverage, and a migration guide,
plus warning filters to keep -Werror runs green.

Closes uncscode#1069

ADW-ID: 029a4449
Successfully fixed:
- Annotated vapor_pressure_strategy selection in to_species to satisfy type validation.
- Split concentration normalization into scalar, vector, and matrix paths to enforce shape checking and handle legacy single-species arrays.
- Kept negative-concentration checks before dtype casting for setters to avoid redundant conversion and ensure consistent validation.
- Refreshed strategy array docstrings and facade/private test docstrings to satisfy validation expectations.

Still failing:
- None; targeted validation gaps are resolved.

Closes uncscode#1069

ADW-ID: 029a4449
Copilot AI review requested due to automatic review settings February 16, 2026 19:42
@Gorkowski Gorkowski added agent Created or managed by ADW automation blocked Blocked - review required before ADW can process labels Feb 16, 2026
Copy link
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 pull request refactors GasSpecies into a facade over the new GasData container while maintaining full backward compatibility. The facade delegates data access to GasData but retains vapor-pressure strategies as behavior, emitting deprecation warnings to guide users toward the new data-first API.

Changes:

  • Refactored GasSpecies to wrap GasData internally with mode tracking for scalar/array returns
  • Added deprecation warnings in __init__ and from_data classmethod for warning-free conversions
  • Updated to_species converter to use GasSpecies.from_data to avoid deprecation warnings
  • Added comprehensive test coverage for facade behavior, conversions, and private helpers
  • Created migration guide documenting the transition path

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
particula/gas/species.py Refactored as facade over GasData with normalization helpers, mode tracking, deprecation warnings, and atomic data operations
particula/gas/gas_data.py Updated to_species to use GasSpecies.from_data for warning-free conversion
particula/gas/tests/species_facade_test.py New facade-level tests for deprecation warnings, delegation, and data updates
particula/gas/tests/species_private_test.py New unit tests for normalization helpers and private methods
particula/gas/tests/gas_data_test.py Added test for warning-free conversion via to_species
conftest.py Added deprecation warning filters and updated scipy patching logic
particula/conftest.py Added deprecation warning filters and updated scipy patching logic
pyproject.toml Registered GasSpecies deprecation filter for pytest defaults
docs/migration/particle-data.md New migration guide for transitioning from facades to data containers

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

@Gorkowski
Copy link
Collaborator Author

change the deprecation warnings, to info logs, like we did for the particle representation data facade

@Gorkowski Gorkowski added request:fix Request AI to implement review suggestions adw:in-progress ADW workflow actively processing - remove to re-trigger and removed blocked Blocked - review required before ADW can process labels Feb 16, 2026
@Gorkowski
Copy link
Collaborator Author

Gorkowski commented Feb 16, 2026

🤖 Agent Developer Workflow

  • Description: Direct PR fix workflow triggered by request:fix label. Analyzes actionable review comments, generates fix plan, implements changes, validates, polishes, tests, formats, and ships fixes without creating intermediate GitHub issues.
  • ADW ID: 2aaa655b
  • Current Phase: Workflow completed successfully
  • Current Step: Analyze actionable PR review comments and generate implementation plan
  • Started: 2026-02-16T20:25:35.391828Z
  • Last Update: 2026-02-16T20:38:50.454054Z

Current Status

  • Workflow completed in 13m 13s

Workflow Plan

  • ✅ Analyze PR Comments (at 2026-02-16T20:25:58.204985Z)
  • ✅ Build Implementation (at 2026-02-16T20:26:25.531034Z)
  • ✅ Validate Implementation and Fix Gaps (at 2026-02-16T20:26:53.576765Z)
  • ✅ Polish Code (at 2026-02-16T20:27:15.375856Z)
  • ✅ Run Tests (at 2026-02-16T20:37:15.842999Z)
  • ✅ Format Code and Add Docstrings (at 2026-02-16T20:37:59.207260Z)
  • ✅ Ship Fix (at 2026-02-16T20:38:48.811580Z)
📋 Recent Activity
[2026-02-16T20:26:53.576781Z] Completed step 3/7: Validate Implementation and Fix Gaps
[2026-02-16T20:26:55.242732Z] Starting step 4/7: Polish Code
[2026-02-16T20:27:15.375871Z] Completed step 4/7: Polish Code
[2026-02-16T20:27:17.087418Z] Starting step 5/7: Run Tests
[2026-02-16T20:37:15.843015Z] Completed step 5/7: Run Tests
[2026-02-16T20:37:17.631880Z] Starting step 6/7: Format Code and Add Docstrings
[2026-02-16T20:37:59.207278Z] Completed step 6/7: Format Code and Add Docstrings
[2026-02-16T20:38:01.047648Z] Starting step 7/7: Ship Fix
[2026-02-16T20:38:48.811598Z] Completed step 7/7: Ship Fix
[2026-02-16T20:38:50.452249Z] Workflow pr-fix finished: 7/7 steps completed
🔍 Archived Updates
[2026-02-16T20:25:35.462504Z] Workflow pr-fix started with 7 steps
[2026-02-16T20:25:37.572894Z] Starting step 1/7: Analyze PR Comments
[2026-02-16T20:25:58.205012Z] Completed step 1/7: Analyze PR Comments
[2026-02-16T20:26:00.150598Z] Starting step 2/7: Build Implementation
[2026-02-16T20:26:25.531058Z] Completed step 2/7: Build Implementation
[2026-02-16T20:26:27.285821Z] Starting step 3/7: Validate Implementation and Fix Gaps

This comment is automatically updated as the workflow progresses

…and move migration docs to Features

Replace warnings.warn(DeprecationWarning) with logger.info() in
GasSpecies facade to match the ParticleRepresentation pattern.
Remove redundant warnings.warn(UserWarning) from
_check_if_negative_concentration() which already had logger.warning().

Move particle-data migration guide from docs/migration/ to
docs/Features/particle-data-migration.md and add it to the Features
index. Update all deprecation message paths accordingly.

Update test files to use caplog logger assertions instead of
pytest.warns for deprecation and warning checks. Clean up dead
GasSpecies DeprecationWarning filters from pyproject.toml and
conftest.py.
@Gorkowski Gorkowski merged commit 7151b4c into uncscode:main Feb 17, 2026
7 checks passed
@Gorkowski Gorkowski deleted the issue-1069-adw-029a4449 branch February 17, 2026 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adw:in-progress ADW workflow actively processing - remove to re-trigger agent Created or managed by ADW automation request:fix Request AI to implement review suggestions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Phase E3-F4-P2] Create GasSpecies facade over GasData with deprecation warnings and tests

1 participant