Skip to content

refactor: Separate GMM parameter extraction and temperature conversion#164

Merged
henry2004y merged 2 commits into
mainfrom
refactor-gmm-parameter-extraction
Nov 17, 2025
Merged

refactor: Separate GMM parameter extraction and temperature conversion#164
henry2004y merged 2 commits into
mainfrom
refactor-gmm-parameter-extraction

Conversation

@henry2004y

Copy link
Copy Markdown
Owner

Refactors the get_gmm_parameters method in AMReXParticleData to separate the core logic of extracting squared thermal velocities from the unit conversion to temperature.

  • get_gmm_parameters now returns only the raw squared thermal velocities (variances) from the GMM's covariance matrix.
  • A new method, get_gmm_temperatures, has been added to handle the conversion of these velocities to temperatures in Kelvin.
  • The documentation notebook amrex_data.ipynb and the relevant tests in tests/test_gmm_parameters.py have been updated to reflect these changes.

Refactors the `get_gmm_parameters` method in `AMReXParticleData` to separate the core logic of extracting squared thermal velocities from the unit conversion to temperature.

- `get_gmm_parameters` now returns only the raw squared thermal velocities (variances) from the GMM's covariance matrix.
- A new method, `get_gmm_temperatures`, has been added to handle the conversion of these velocities to temperatures in Kelvin.
- The documentation notebook `amrex_data.ipynb` and the relevant tests in `tests/test_gmm_parameters.py` have been updated to reflect these changes.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @henry2004y, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the AMReXParticleData class by separating the concerns of extracting raw Gaussian Mixture Model (GMM) parameters from their physical unit conversion to temperature. This refactoring improves code modularity, making the parameter extraction logic clearer and more flexible for future extensions or alternative unit conversions.

Highlights

  • Method Refactoring: The get_gmm_parameters method in AMReXParticleData has been refactored to solely extract raw squared thermal velocities from GMM covariance matrices, removing the particle_mass argument.
  • New Temperature Conversion Method: A new static method, get_gmm_temperatures, has been introduced to handle the conversion of these extracted velocities into temperatures in Kelvin, taking particle_mass as an argument.
  • Documentation Update: The amrex_data.ipynb notebook has been updated to reflect the usage of the new get_gmm_temperatures method and to demonstrate the raw velocity extraction.
  • Test Suite Enhancement: The test suite (tests/test_gmm_parameters.py) has been updated with new tests for get_gmm_parameters and modified existing tests to validate get_gmm_temperatures.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov

codecov Bot commented Nov 17, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.39%. Comparing base (399e168) to head (a3839b0).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #164      +/-   ##
==========================================
+ Coverage   68.31%   68.39%   +0.08%     
==========================================
  Files          25       25              
  Lines        4191     4202      +11     
==========================================
+ Hits         2863     2874      +11     
  Misses       1328     1328              

☔ 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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request is a well-executed refactoring that separates the extraction of GMM parameters from the physics-specific conversion to temperature. By introducing get_gmm_parameters for raw velocity variances and get_gmm_temperatures for the conversion, the code is now more modular and adheres better to the single-responsibility principle. The updates to the documentation notebook and tests are thorough and correctly reflect these changes. I have a couple of suggestions to make the new methods even more concise and Pythonic by using list comprehensions.

Comment thread src/flekspy/amrex/particle_data.py Outdated
Comment thread src/flekspy/amrex/particle_data.py Outdated
Refactors the `get_gmm_parameters` and `get_gmm_temperatures` methods in `AMReXParticleData` to use list comprehensions instead of for-loops.

This change improves the conciseness and readability of the code, making it more idiomatic Python.
@henry2004y henry2004y merged commit fddd9e4 into main Nov 17, 2025
3 checks passed
@henry2004y henry2004y deleted the refactor-gmm-parameter-extraction branch November 17, 2025 04:00
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.

1 participant