Skip to content

Improve reliability and tests for map_particle_hole_dm_to_one_pdm#1241

Open
mhucka wants to merge 3 commits intoquantumlib:mainfrom
mhucka:improve-rdm-mapping-tests-17490794947821494422
Open

Improve reliability and tests for map_particle_hole_dm_to_one_pdm#1241
mhucka wants to merge 3 commits intoquantumlib:mainfrom
mhucka:improve-rdm-mapping-tests-17490794947821494422

Conversation

@mhucka
Copy link
Contributor

@mhucka mhucka commented Mar 27, 2026

This change addresses a potential ZeroDivisionError in map_particle_hole_dm_to_one_pdm by raising a ValueError when the denominator is zero. It also adds a unit test to verify this behavior and ensure edge cases are handled correctly.

mhucka and others added 2 commits March 27, 2026 04:57
This change addresses a potential ZeroDivisionError in `map_particle_hole_dm_to_one_pdm`
by raising a `ValueError` when the denominator is zero. It also adds a unit test
to verify this behavior and ensure edge cases are handled correctly.
Copy link

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

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 introduces a check to prevent division by zero in the map_particle_hole_dm_to_one_pdm function and adds a corresponding unit test. Feedback suggests that instead of checking for a zero denominator, the code should validate that the number of particles does not exceed the number of basis functions, which is the underlying physical constraint.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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