Skip to content

Commit a1cfbbb

Browse files
committed
Clean up merge
1 parent a740c6f commit a1cfbbb

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/constants.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
module Constants
22

3-
import ..DEFAULT_QUANTITY_TYPE
43
import ..Quantity
54
import ..Units as U
6-
import ..Units: _add_prefixes
5+
import ..Units: _add_prefixes, DEFAULT_UNIT_TYPE
76

87
const _CONSTANT_SYMBOLS = Symbol[]
9-
const _CONSTANT_VALUES = DEFAULT_QUANTITY_TYPE[]
8+
const _CONSTANT_VALUES = DEFAULT_UNIT_TYPE[]
109

1110
macro register_constant(name, value)
1211
return esc(_register_constant(name, value))
@@ -20,7 +19,7 @@ end
2019
function _register_constant(name::Symbol, value)
2120
s = string(name)
2221
return quote
23-
const $name = $value
22+
const $name = convert(DEFAULT_UNIT_TYPE, $value)
2423
push!(_CONSTANT_SYMBOLS, Symbol($s))
2524
push!(_CONSTANT_VALUES, $name)
2625
end
@@ -87,7 +86,7 @@ end
8786
)
8887

8988
# Measured
90-
@register_constant alpha DEFAULT_QUANTITY_TYPE(7.2973525693e-3)
89+
@register_constant alpha DEFAULT_UNIT_TYPE(7.2973525693e-3)
9190
@register_constant u 1.66053906660e-27 * U.kg
9291
@register_constant G 6.67430e-11 * U.m^3 / (U.kg * U.s^2)
9392
@register_constant mu_0 4π * alpha * hbar / (e^2 * c)

src/lazy_float.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ Base.convert(::Type{LazyFloat64}, x::LazyFloat64) = x
1212
Base.convert(::Type{LazyFloat64}, x::FixedRational) = LazyFloat64(convert(Float64, x))
1313
Base.convert(::Type{LazyFloat64}, x::Number) = LazyFloat64(x)
1414
Base.convert(::Type{T}, x::LazyFloat64) where {T<:Number} = convert(T, float(x))
15-
Base.promote_rule(::Type{LazyFloat64}, ::Type{T}) where {T} = T
15+
Base.promote_rule(::Type{LazyFloat64}, ::Type{T}) where {T<:AbstractFloat} = T
16+
Base.promote_rule(::Type{LazyFloat64}, ::Type{T}) where {T} = promote_type(Float64, T)
1617

1718
(::Type{T})(x::LazyFloat64) where {T<:Number} = T(float(x))
1819

src/units.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import ..Quantity
77
import ..LazyFloat64
88

99
const DEFAULT_UNIT_BASE_TYPE = LazyFloat64
10-
const DEFAULT_UNIT_TYPE = Quantity{DEFAULT_UNIT_TYPE,DEFAULT_DIM_TYPE}
10+
const DEFAULT_UNIT_TYPE = Quantity{DEFAULT_UNIT_BASE_TYPE,DEFAULT_DIM_TYPE}
1111

1212
const _UNIT_SYMBOLS = Symbol[]
1313
const _UNIT_VALUES = DEFAULT_UNIT_TYPE[]

0 commit comments

Comments
 (0)