Skip to content

Commit 650fa0f

Browse files
committed
feat: create alias for default FixedRational type
1 parent b7ec886 commit 650fa0f

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/DynamicQuantities.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module DynamicQuantities
33
export Units, Constants, SymbolicUnits, SymbolicConstants
44
export AbstractQuantity, AbstractGenericQuantity, AbstractRealQuantity, UnionAbstractQuantity
55
export Quantity, GenericQuantity, RealQuantity
6-
export FixedRational
6+
export FixedRational, FRInt32, FRInt8
77
export AbstractDimensions, Dimensions, NoDims
88
export AbstractSymbolicDimensions, SymbolicDimensions, SymbolicDimensionsSingleton
99
export QuantityArray

src/types.jl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,21 @@ else
44
@eval const static_fieldnames = fieldnames
55
end
66

7-
const DEFAULT_DIM_BASE_TYPE = FixedRational{DEFAULT_NUMERATOR_TYPE,DEFAULT_DENOM}
7+
"""
8+
FRInt32
9+
10+
FixedRational with Int32 numerator and denominator 25200.
11+
"""
12+
const FRInt32 = FixedRational{DEFAULT_NUMERATOR_TYPE,DEFAULT_DENOM}
13+
14+
"""
15+
FRInt8
16+
17+
FixedRational with Int8 numerator and denominator 12.
18+
"""
19+
const FRInt8 = FixedRational{Int8, 12}
20+
21+
const DEFAULT_DIM_BASE_TYPE = FRInt32
822
const DEFAULT_VALUE_TYPE = Float64
923

1024
"""

test/unittests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,15 @@ end
737737
x = 10u"m"
738738
user_quantity = Quantity(10.0, Dimensions{FixedRational{Int32,25200}}(1, 0, 0, 0, 0, 0, 0))
739739
@test x == user_quantity
740+
741+
@testset "FRInt32 and FRInt8 type aliases" begin
742+
@test FRInt32 === FixedRational{Int32, 25200}
743+
@test FRInt8 === FixedRational{Int8, 12}
744+
@test DEFAULT_DIM_BASE_TYPE === FRInt32
745+
746+
@test string(FRInt32) == "FRInt32"
747+
@test string(FRInt8) == "FRInt8"
748+
end
740749
end
741750

742751
@testset "Quantity promotion" begin

0 commit comments

Comments
 (0)