|
697 | 697 | # Actually expands to:
|
698 | 698 | @test string(dimension(us"Constants.h")) == "h_constant"
|
699 | 699 |
|
700 |
| - # So the numerical value is different from other constants: |
701 |
| - @test ustrip(us"Constants.h") == ustrip(u"Constants.h") |
| 700 | + # Constants have different numerical value from non-symbolic one: |
| 701 | + @test ustrip(us"Constants.h") != ustrip(u"Constants.h") |
702 | 702 | @test ustrip(us"Constants.au") != ustrip(u"Constants.au")
|
703 | 703 |
|
704 | 704 | # Test conversion
|
@@ -912,10 +912,10 @@ end
|
912 | 912 | @test x[5] == Q(5, length=1, time=-1)
|
913 | 913 |
|
914 | 914 | y = randn(32)
|
915 |
| - @test ustrip(QuantityArray(y, Q(u"m"))) == y |
| 915 | + @test ustrip(QuantityArray(y, Q(u"m"))) ≈ y |
916 | 916 |
|
917 | 917 | f_square(v) = v^2 * 1.5 - v^2
|
918 |
| - @test sum(f_square.(QuantityArray(y, Q(u"m")))) == sum(f_square.(y) .* Q(u"m^2")) |
| 918 | + @test sum(f_square.(QuantityArray(y, Q(u"m")))) ≈ sum(f_square.(y) .* Q(u"m^2")) |
919 | 919 |
|
920 | 920 | y_q = QuantityArray(y, Q(u"m * cd / s"))
|
921 | 921 | @test typeof(f_square.(y_q)) == typeof(y_q)
|
@@ -1057,7 +1057,7 @@ end
|
1057 | 1057 | y_q = QuantityArray(y, Q(u"m"))
|
1058 | 1058 |
|
1059 | 1059 | f4(v) = v^4 * 0.3
|
1060 |
| - @test sum(f4.(QuantityArray(y, Q(u"m")))) == sum(f4.(y) .* Q(u"m^4")) |
| 1060 | + @test sum(f4.(QuantityArray(y, Q(u"m")))) ≈ sum(f4.(y) .* Q(u"m^4")) |
1061 | 1061 |
|
1062 | 1062 | f4v(v) = f4.(v)
|
1063 | 1063 | @inferred f4v(y_q)
|
@@ -1600,9 +1600,8 @@ end
|
1600 | 1600 | y = 5randn(10) .- 2.5
|
1601 | 1601 | for Q in (RealQuantity, Quantity, GenericQuantity), D in (Dimensions, SymbolicDimensions), f in functions
|
1602 | 1602 | ground_truth = @eval $f.($x, $y)
|
1603 |
| - dim = convert(D, dimension(u"m/s")) |
1604 |
| - qx_dimensions = [Q(xi, dim) for xi in x] |
1605 |
| - qy_dimensions = [Q(yi, dim) for yi in y] |
| 1603 | + qx_dimensions = [with_type_parameters(Q, Float64, D)(xi, dim) for xi in x] |
| 1604 | + qy_dimensions = [with_type_parameters(Q, Float64, D)(yi, dim) for yi in y] |
1606 | 1605 | @eval @test all($f.($qx_dimensions, $qy_dimensions) .== $ground_truth)
|
1607 | 1606 | if f in (:isequal, :(==))
|
1608 | 1607 | # These include a dimension check in the result, rather than
|
|
0 commit comments