@@ -400,9 +400,10 @@ module SymbolicUnits
400
400
`Quantity(1.0, SymbolicDimensions, c=2, Hz=2)`. However, note that due to
401
401
namespace collisions, a few physical constants are automatically converted.
402
402
"""
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
406
407
end
407
408
408
409
as_quantity (q:: DEFAULT_SYMBOLIC_QUANTITY_OUTPUT_TYPE ) = q
@@ -445,9 +446,7 @@ module SymbolicUnits
445
446
end
446
447
end
447
448
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
451
450
452
451
"""
453
452
us"[unit expression]"
@@ -465,8 +464,9 @@ module. So, for example, `us"Constants.c^2 * Hz^2"` would evaluate to
465
464
namespace collisions, a few physical constants are automatically converted.
466
465
"""
467
466
macro 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)
470
470
end
471
471
472
472
function Base. promote_rule (:: Type{SymbolicDimensionsSingleton{R1}} , :: Type{SymbolicDimensionsSingleton{R2}} ) where {R1,R2}
0 commit comments