Skip to content

Remove multiplate states#654

Merged
K20shores merged 3 commits intomainfrom
remove_multiplate_states
Dec 4, 2025
Merged

Remove multiplate states#654
K20shores merged 3 commits intomainfrom
remove_multiplate_states

Conversation

@K20shores
Copy link
Copy Markdown
Collaborator

In conjunction with the work the students are doing in #642, I realized that we were not handling multiple grid cells in a single state like I thought we were.

This PR removes multiple states and stores all grid cells in a single state in the Python API. I think the reason we did what we did before was for the cuda solver. The cuda solver always expects the number of grid cells to equal the vector length, but this will be changing soon. For that reason, this PR can wait until those updates are made in micm (which should be part of the resolution of NCAR/micm#857).

To handle multiple grid cells, it's a special case specifically for the vector ordered matrix, where we need to ensure we properly index our data structures by explicitly taking into account the vector length, which we are now doing. It worked before because we would create as many internal states who only stored a vector lengths worth of grid cell data

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 refactors the Python API to store all grid cells in a single internal state instead of using multiple state objects. Previously, the code would split grid cells across multiple states based on the vector size, but this approach is being simplified to use a single state with explicit vector-aware indexing for the vector ordered matrix case.

Key Changes

  • Removed multiple internal states in favor of a single state object
  • Implemented explicit vector-aware indexing for concentrations, rate parameters, and conditions
  • Updated vector size default from 1 to 4 for standard order solvers
  • Added comprehensive test coverage for 6 grid cells to validate the refactoring

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
python/musica/micm/state.py Core refactoring - replaced multiple states list with single state object and added vector-aware indexing logic
python/musica/micm/micm.py Simplified solve method to use single state instead of iterating over multiple states
python/musica/bindings/micm/micm.cpp Changed vector size for standard order solvers from 0 to 1
pyproject.toml Increased default MICM vector size from 1 to 4
python/musica/test/unit/micm/test_state.py Added extensive tests for 6 grid cells to validate new single-state approach
python/musica/test/integration/test_sulfate_box_model.py Added pytest.main boilerplate for direct script execution

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions
Copy link
Copy Markdown
Contributor

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 15, 2025

Codecov Report

❌ Patch coverage is 98.14815% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.55%. Comparing base (4713fe6) to head (4633d9e).

Files with missing lines Patch % Lines
python/musica/micm/state.py 98.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #654      +/-   ##
==========================================
+ Coverage   81.52%   81.55%   +0.03%     
==========================================
  Files         114      114              
  Lines        9921     9912       -9     
==========================================
- Hits         8088     8084       -4     
+ Misses       1833     1828       -5     
Flag Coverage Δ
cpp_fortran 79.71% <ø> (ø)
javascript 92.12% <ø> (ø)
python 82.71% <98.14%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@K20shores K20shores force-pushed the remove_multiplate_states branch from 7d3decf to 3967b53 Compare December 2, 2025 21:50
@K20shores K20shores force-pushed the remove_multiplate_states branch from 3967b53 to 4633d9e Compare December 2, 2025 22:23
@K20shores K20shores marked this pull request as ready for review December 3, 2025 14:59
@K20shores K20shores merged commit b9a9afa into main Dec 4, 2025
81 checks passed
@K20shores K20shores deleted the remove_multiplate_states branch December 4, 2025 15:03
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.

4 participants