1
+ import .. WriteOnceReadMany
2
+ import .. INDEX_TYPE
1
3
import . Units: UNIT_SYMBOLS, UNIT_MAPPING, UNIT_VALUES
2
4
import . Constants: CONSTANT_SYMBOLS, CONSTANT_MAPPING, CONSTANT_VALUES
3
5
@@ -8,13 +10,9 @@ disambiguate_symbol(s) = s in SYMBOL_CONFLICTS ? Symbol(s, :_constant) : s
8
10
# Prefer units over constants:
9
11
# For example, this means we can't have a symbolic Planck's constant,
10
12
# as it is just "hours" (h), which is more common.
11
- const INDEX_TYPE = UInt16
12
- # Prefer units over constants:
13
- # For example, this means we can't have a symbolic Planck's constant,
14
- # as it is just "hours" (h), which is more common.
15
- const ALL_SYMBOLS = [UNIT_SYMBOLS... , disambiguate_symbol .(CONSTANT_SYMBOLS)... ]
16
- const ALL_VALUES = [UNIT_VALUES... , CONSTANT_VALUES... ]
17
- const ALL_MAPPING = Dict (ALL_SYMBOLS .=> (INDEX_TYPE (1 ): INDEX_TYPE (length (ALL_SYMBOLS))))
13
+ const ALL_SYMBOLS = WriteOnceReadMany ([UNIT_SYMBOLS... , disambiguate_symbol .(CONSTANT_SYMBOLS)... ])
14
+ const ALL_VALUES = WriteOnceReadMany ([UNIT_VALUES... , CONSTANT_VALUES... ])
15
+ const ALL_MAPPING = WriteOnceReadMany (Dict (s => INDEX_TYPE (i) for (i, s) in enumerate (ALL_SYMBOLS)))
18
16
19
17
"""
20
18
AbstractSymbolicDimensions{R} <: AbstractDimensions{R}
@@ -375,6 +373,7 @@ module SymbolicUnits
375
373
import .. DEFAULT_SYMBOLIC_QUANTITY_OUTPUT_TYPE
376
374
import .. DEFAULT_VALUE_TYPE
377
375
import .. DEFAULT_DIM_BASE_TYPE
376
+ import .. WriteOnceReadMany
378
377
379
378
# Lazily create unit symbols (since there are so many)
380
379
module Constants
@@ -403,7 +402,7 @@ module SymbolicUnits
403
402
import . Constants as SymbolicConstants
404
403
import . Constants: SYMBOLIC_CONSTANT_VALUES
405
404
406
- const SYMBOLIC_UNIT_VALUES = DEFAULT_SYMBOLIC_QUANTITY_TYPE[]
405
+ const SYMBOLIC_UNIT_VALUES = WriteOnceReadMany {Vector{ DEFAULT_SYMBOLIC_QUANTITY_TYPE}} ()
407
406
408
407
function update_symbolic_unit_values! (unit, symbolic_unit_values = SYMBOLIC_UNIT_VALUES)
409
408
@eval begin
@@ -415,7 +414,8 @@ module SymbolicUnits
415
414
end
416
415
end
417
416
418
- update_symbolic_unit_values! .(UNIT_SYMBOLS)
417
+ update_symbolic_unit_values! (w:: WriteOnceReadMany ) = update_symbolic_unit_values! .(w. _raw_data)
418
+ update_symbolic_unit_values! (UNIT_SYMBOLS)
419
419
420
420
"""
421
421
sym_uparse(raw_string::AbstractString)
0 commit comments