@@ -400,9 +400,10 @@ module SymbolicUnits
400400 `Quantity(1.0, SymbolicDimensions, c=2, Hz=2)`. However, note that due to
401401 namespace collisions, a few physical constants are automatically converted.
402402 """
403- function sym_uparse (raw_string:: AbstractString )
404- raw_result = eval (map_to_scope (Meta. parse (raw_string)))
405- return copy (as_quantity (raw_result)):: DEFAULT_SYMBOLIC_QUANTITY_OUTPUT_TYPE
403+ function sym_uparse (s:: AbstractString )
404+ ex = map_to_scope (Meta. parse (s))
405+ ex = :($ as_quantity ($ ex))
406+ return copy (eval (ex)):: DEFAULT_SYMBOLIC_QUANTITY_OUTPUT_TYPE
406407 end
407408
408409 as_quantity (q:: DEFAULT_SYMBOLIC_QUANTITY_OUTPUT_TYPE ) = q
@@ -445,9 +446,7 @@ module SymbolicUnits
445446 end
446447end
447448
448- import . SymbolicUnits: sym_uparse
449- import . SymbolicUnits: SymbolicConstants
450- import . SymbolicUnits: map_to_scope
449+ import . SymbolicUnits: as_quantity, sym_uparse, SymbolicConstants, map_to_scope
451450
452451"""
453452 us"[unit expression]"
@@ -465,8 +464,9 @@ module. So, for example, `us"Constants.c^2 * Hz^2"` would evaluate to
465464namespace collisions, a few physical constants are automatically converted.
466465"""
467466macro us_str (s)
468- ex = Meta. parse (s)
469- return esc (map_to_scope (ex))
467+ ex = map_to_scope (Meta. parse (s))
468+ ex = :($ as_quantity ($ ex))
469+ return esc (ex)
470470end
471471
472472function Base. promote_rule (:: Type{SymbolicDimensionsSingleton{R1}} , :: Type{SymbolicDimensionsSingleton{R2}} ) where {R1,R2}
0 commit comments