Skip to content

Commit df362d3

Browse files
committed
Make si.py a real file again
1 parent e82c9ed commit df362d3

2 files changed

Lines changed: 41 additions & 28 deletions

File tree

sasdata/quantities/__init__.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -457,28 +457,3 @@ def format_name(name: str):
457457
units = importlib.import_module(".units", "sasdata.quantities")
458458
# Execute the code that we've created within that module
459459
exec(fid.getvalue(), units.__dict__)
460-
461-
462-
with StringIO() as fid:
463-
si_unit_names = [values.plural for values in base_si_units + derived_si_units if values.plural != "grams"] + [
464-
"kilograms"
465-
]
466-
si_unit_names.sort()
467-
468-
fid.write("from sasdata.quantities.units import (\n")
469-
470-
for name in si_unit_names:
471-
fid.write(f" {name},\n")
472-
473-
fid.write(")\n")
474-
fid.write("\nall_si = [\n")
475-
476-
for name in si_unit_names:
477-
fid.write(f" {name},\n")
478-
479-
fid.write("]\n")
480-
481-
# Load the units module
482-
si = importlib.import_module(".si", "sasdata.quantities")
483-
# Execute the code that we've created within that module
484-
exec(fid.getvalue(), si.__dict__)

sasdata/quantities/si.py

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
1-
# This file is intentionally blank. It needs to exist so that the
2-
# module loader can load it as a module, but the actual contents are
3-
# dynamically created in __init__.py
1+
from sasdata.quantities.units import (
2+
seconds,
3+
meters,
4+
kilograms,
5+
amperes,
6+
kelvin,
7+
hertz,
8+
newtons,
9+
pascals,
10+
joules,
11+
watts,
12+
coulombs,
13+
volts,
14+
ohms,
15+
farads,
16+
siemens,
17+
webers,
18+
tesla,
19+
henry,
20+
)
21+
22+
all_si = [
23+
seconds,
24+
meters,
25+
kilograms,
26+
amperes,
27+
kelvin,
28+
hertz,
29+
newtons,
30+
pascals,
31+
joules,
32+
watts,
33+
coulombs,
34+
volts,
35+
ohms,
36+
farads,
37+
siemens,
38+
webers,
39+
tesla,
40+
henry,
41+
]

0 commit comments

Comments
 (0)