Convert wavenumbers to Hz, not GHz - #1904
Open
dylanpulver wants to merge 1 commit into
Open
dylanpulver wants to merge 1 commit into
dylanpulver wants to merge 1 commit into
Conversation
convertor(x, "wavenumber", "Hz") multiplied by 29.9792458, which is c expressed in GHz per cm^-1, so the returned value was 1e9 too small for the unit the key names. The SI value of c gives 2.99792458e10 Hz per cm^-1. Nothing in cclib calls this key, and the existing round-trip test only compares unit pairs that have both directions in the table, so "Hz" (which has no inverse entry) could never be checked.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
convertor(x, "wavenumber", "Hz")multiplies by29.9792458, which is c expressed in GHz per cm⁻¹, so the result is 1e9 too small for the unit the key names. With c = 299792458 m/s (exact, SI) and 1 cm⁻¹ = 100 m⁻¹, one wavenumber is 2.99792458e10 Hz.Cross-check that stays inside the table: on master,
convertor(convertor(1, "hartree", "wavenumber"), "wavenumber", "Hz")gives 6.5797e6, against the CODATA 2010 hartree–hertz relationship of 6.579683920729e15.Why it survived: nothing in cclib calls this key —
nuclear.rotational_constantsbuilds its own cm⁻¹↔GHz factor fromscipy.constants— andtest_pairsonly checks unit pairs that have both directions in the table.Hzhas no inverse entry, so it sits outside the only test that looks at these values.There is a second defensible remedy and I would rather name it than hide it: rename the key to
wavenumber_to_GHzand keep the number, which is the shape #461 got (hartree_to_kcal→hartree_to_kcal/mol). I went the other way becauseHzis a real unit, every other key in the dict returns the unit it names, and a GHz path already exists innuclear.py. Happy to flip it if you prefer the rename.Ran
pytest test/parser test/method test/ioon master and on the branch in the same venv: 0 failed / 204 passed / 5 skipped → 205 passed. An earlier version of this description reported 17 failures on both legs; those came from an under-provisioned checkout rather than from the suite.ruff checkandruff format --checkclean at the pinned 0.15.22. Reverting the constant fails the new test; renaming the key to GHz fails it; a rounded3.0e10fails it.AI assistance: this change was drafted with Claude Opus 5 (
claude-opus-5).