Skip to content

Add ureg.constants for accessing physical constants#2299

Open
andrewgsavage wants to merge 12 commits into
hgrecco:masterfrom
andrewgsavage:fix/constants-1078-v2
Open

Add ureg.constants for accessing physical constants#2299
andrewgsavage wants to merge 12 commits into
hgrecco:masterfrom
andrewgsavage:fix/constants-1078-v2

Conversation

@andrewgsavage

@andrewgsavage andrewgsavage commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds ureg.constants accessor for convenient access to physical constants
  • Adds __dir__ to Group for autocomplete support

Closes #1078

andrewgsavage and others added 6 commits April 17, 2026 22:57
hgrecco#1078)

Physical constants are now accessible as Quantity objects via ureg.constants.<name>
(in default system base units) and ureg.sys.<system>.<name> (in system-specific
base units), while ureg.<name> continues to return a Unit for backward compatibility.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ureg.sys.imperial.speed_of_light now returns a Unit (unchanged behaviour).
ureg.sys.imperial.constants.speed_of_light returns a Quantity in the
system's base units via a new SystemConstantsAccessor class.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Access to constants in system units is available via
ureg.constants.<name>.to_base_units(system=<system>).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@andrewgsavage andrewgsavage changed the title Add ureg.constants and ureg.sys.<system> access for physical constants Add ureg.constants for accessing physical constants Apr 17, 2026
andrewgsavage and others added 2 commits April 17, 2026 23:29
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codspeed-hq

codspeed-hq Bot commented Apr 17, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 448 untouched benchmarks
⏩ 448 skipped benchmarks1


Comparing andrewgsavage:fix/constants-1078-v2 (8c87251) with master (af29dc0)2

Open in CodSpeed

Footnotes

  1. 448 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on master (bf935fc) during the generation of this report, so af29dc0 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

andrewgsavage and others added 4 commits April 18, 2026 08:41
…mbership

Aliases like ureg.constants.c now correctly return a Quantity
instead of falling through to the Unit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@andrewgsavage

Copy link
Copy Markdown
Collaborator Author

This is ready for merging.
I've left out anything related to systems.<sys>.constants since you can now do

ureg.constants.c.to_base_units('imperial') 
327857018.8101487 yard / second

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.

Make physical constants (numerically) more easily accessible

1 participant