Skip to content

units: make the angle a dimension, so 1 Hz is 2π rad/s - #1

Open
m-messer wants to merge 1 commit into
mainfrom
fix/radian-dimension
Open

m-messer wants to merge 1 commit into
mainfrom
fix/radian-dimension

Conversation

@m-messer

Copy link
Copy Markdown
Member

Problem

The radian was 1 and the hertz 1/second, so 1 rad/s equalled 1 Hz. Physically, 1 Hz is one cycle per second, which is 2π rad/s. Because of this, the upstream test_radians_to_frequency (2*pi*f radian/second vs f Hz) failed.

Change

The angle is now a dimension:

  • The radian is a base unit (RADIAN) with the dimension angle. It stays in the common set with the symbol r. The new BASE_UNITS holds it together with SI_BASE_UNITS.
  • hertz = 2*pi*radian/second, i.e. a cycle per second. becquerel stays 1/second.
  • steradian = radian**2. Degree, arcminute and arcsecond are multiples of the radian. Lumen and lux now include the sr factor.
  • quantity.py uses BASE_UNITS, so the radian's factor is pulled out like the other base units' and it gets the angle dimension.

Breaking

These pairs no longer have the same dimension, so same_dimension returns False for them:

  • 1 rad and 1
  • 1 Hz and 1/s
  • 1 Hz and 1 Bq

Responses that mix them, e.g. 50 s^-1 for a frequency or a bare number for an angle, now give a dimension mismatch. The README and CHANGELOG describe the new behaviour.

The earlier 0.3.0 CHANGELOG entry ("radian and steradian are now 1") is now partly out of date and could be merged with the new entry before release.

Testing

  • units 538, criteria 73, expression_parsing 466 and slr_parsing 115 tests pass.
  • New regression tests: the hertz is a cycle per second, and a mirror of the upstream test_radians_to_frequency.
  • Parity check: 0 unexpected and 0 mismatched. I reviewed the 62 angle/Hz/lumen/lux diffs and recorded them in expected_changes.json.
  • ruff and mypy are clean.

🤖 Generated with Claude Code

The radian was 1 and the hertz 1/second, so 1 rad/s equalled 1 Hz. The
radian is now a base unit (RADIAN, dimension 'angle', in the common set),
collected with SI_BASE_UNITS in the new BASE_UNITS. The hertz is a cycle
per second (2*pi*radian/second), the steradian radian**2, and the degree,
arcminute, arcsecond, lumen and lux are expressed in it. 2*pi*f rad/s now
equals f Hz; 1 rad vs 1 and 1 Hz vs 1/s differ in dimension.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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