Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,5 @@ ignore = []
"quantities/units/*.py" = ["F401"]
"quantities/constants/*.py" = ["F401"]
"quantities/__init__.py" = ["F401", "F403"]
# Generated from NIST_codata.txt with one constant per line.
"quantities/constants/_codata.py" = ["E501"]
2 changes: 1 addition & 1 deletion quantities/constants/NIST_codata.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Fundamental Physical Constants --- Complete Listing

2006 CODATA adjustment

From: http://physics.nist.gov/constants

Expand Down
1 change: 1 addition & 0 deletions quantities/constants/_codata.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# THIS FILE IS AUTOMATICALLY GENERATED
# ANY CHANGES MADE HERE WILL BE LOST
# Source: CODATA 2006 recommended values, from NIST_codata.txt

physical_constants = {}

Expand Down
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import re

from setuptools import Command, setup
from setuptools.command.build_py import build_py as _build
from setuptools.command.sdist import sdist as _sdist
from datetime import datetime


class data(Command):
Expand All @@ -19,12 +20,15 @@ def finalize_options(self):
def run(self):
with open('quantities/constants/NIST_codata.txt') as f:
data = f.read()
edition = re.search(r'(\d{4}) CODATA adjustment', data)
if edition is None:
raise ValueError('CODATA edition not found in NIST_codata.txt')
data = data.split('\n')[10:-1]

with open('quantities/constants/_codata.py', 'w') as f:
f.write('# THIS FILE IS AUTOMATICALLY GENERATED\n')
f.write('# ANY CHANGES MADE HERE WILL BE LOST\n')
f.write(f'# LAST GENERATED: {datetime.now()}\n\n')
f.write(f'# Source: CODATA {edition[1]} recommended values, from NIST_codata.txt\n\n')
f.write('physical_constants = {}\n\n')
for line in data:
name = line[:55].rstrip().replace('mag.','magnetic')
Expand Down
Loading