Skip to content

Conversation

@MilesCranmer
Copy link
Member

Makes the printouts easier to read. Also this creates FRInt8=FixedRational{Int8,12} which makes it less challenging to swap the dimensions type.

@icweaver would you be up for a review?

@github-actions
Copy link
Contributor

github-actions bot commented Sep 13, 2025

Benchmark Results (Julia v1.10)

Time benchmarks
main 0148cb2... main / 0148cb2...
Quantity/creation/Quantity(x) 3.72 ± 0.01 ns 4.33 ± 0.01 ns 0.859 ± 0.003
Quantity/creation/Quantity(x, length=y) 3.41 ± 0.01 ns 3.11 ± 0.01 ns 1.1 ± 0.0048
Quantity/with_numbers/*real 3.1 ± 0.01 ns 3.11 ± 0.01 ns 1 ± 0.0046
Quantity/with_numbers/^int 8.37 ± 2.5 ns 8.05 ± 2.2 ns 1.04 ± 0.41
Quantity/with_numbers/^int * real 8.05 ± 2.2 ns 8.67 ± 2.5 ns 0.929 ± 0.37
Quantity/with_quantity/+y 4.04 ± 0.001 ns 4.04 ± 0.01 ns 1 ± 0.0025
Quantity/with_quantity//y 3.11 ± 0.001 ns 3.42 ± 0.01 ns 0.909 ± 0.0027
Quantity/with_self/dimension 2.79 ± 0.01 ns 3.11 ± 0.01 ns 0.9 ± 0.0043
Quantity/with_self/inv 3.11 ± 0.001 ns 3.11 ± 0.01 ns 1 ± 0.0032
Quantity/with_self/ustrip 2.79 ± 0.01 ns 2.79 ± 0.01 ns 0.996 ± 0.0051
QuantityArray/broadcasting/multi_array_of_quantities 0.144 ± 0.0025 ms 0.144 ± 0.0015 ms 0.997 ± 0.02
QuantityArray/broadcasting/multi_normal_array 0.0528 ± 0.0028 ms 0.0558 ± 0.003 ms 0.947 ± 0.072
QuantityArray/broadcasting/multi_quantity_array 0.157 ± 0.00085 ms 0.155 ± 0.00078 ms 1.01 ± 0.0075
QuantityArray/broadcasting/x^2_array_of_quantities 25.9 ± 2.4 μs 24.4 ± 2 μs 1.06 ± 0.13
QuantityArray/broadcasting/x^2_normal_array 5.61 ± 0.74 μs 5.33 ± 0.59 μs 1.05 ± 0.18
QuantityArray/broadcasting/x^2_quantity_array 6.95 ± 0.26 μs 6.94 ± 0.35 μs 1 ± 0.063
QuantityArray/broadcasting/x^4_array_of_quantities 0.0847 ± 0.00054 ms 0.0817 ± 0.00063 ms 1.04 ± 0.01
QuantityArray/broadcasting/x^4_normal_array 0.0497 ± 0.003 ms 0.0498 ± 0.00018 ms 0.997 ± 0.061
QuantityArray/broadcasting/x^4_quantity_array 0.05 ± 0.00018 ms 0.053 ± 0.00018 ms 0.943 ± 0.0047
time_to_load 0.205 ± 0.0023 s 0.205 ± 0.0025 s 1 ± 0.017
Memory benchmarks
main 0148cb2... main / 0148cb2...
Quantity/creation/Quantity(x) 0 allocs: 0 B 0 allocs: 0 B
Quantity/creation/Quantity(x, length=y) 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_numbers/*real 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_numbers/^int 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_numbers/^int * real 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_quantity/+y 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_quantity//y 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_self/dimension 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_self/inv 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_self/ustrip 0 allocs: 0 B 0 allocs: 0 B
QuantityArray/broadcasting/multi_array_of_quantities 2 allocs: 0.382 MB 2 allocs: 0.382 MB 1
QuantityArray/broadcasting/multi_normal_array 2 allocs: 0.0763 MB 2 allocs: 0.0763 MB 1
QuantityArray/broadcasting/multi_quantity_array 2 allocs: 0.0763 MB 2 allocs: 0.0763 MB 1
QuantityArray/broadcasting/x^2_array_of_quantities 2 allocs: 0.382 MB 2 allocs: 0.382 MB 1
QuantityArray/broadcasting/x^2_normal_array 2 allocs: 0.0763 MB 2 allocs: 0.0763 MB 1
QuantityArray/broadcasting/x^2_quantity_array 2 allocs: 0.0763 MB 2 allocs: 0.0763 MB 1
QuantityArray/broadcasting/x^4_array_of_quantities 2 allocs: 0.382 MB 2 allocs: 0.382 MB 1
QuantityArray/broadcasting/x^4_normal_array 2 allocs: 0.0763 MB 2 allocs: 0.0763 MB 1
QuantityArray/broadcasting/x^4_quantity_array 2 allocs: 0.0763 MB 2 allocs: 0.0763 MB 1
time_to_load 0.153 k allocs: 14.5 kB 0.153 k allocs: 14.5 kB 1

@github-actions
Copy link
Contributor

github-actions bot commented Sep 13, 2025

Benchmark Results (Julia v1)

Time benchmarks
main 0148cb2... main / 0148cb2...
Quantity/creation/Quantity(x) 4.02 ± 0.01 ns 3.1 ± 0.01 ns 1.3 ± 0.0053
Quantity/creation/Quantity(x, length=y) 3.73 ± 0.01 ns 3.73 ± 0 ns 1 ± 0.0027
Quantity/with_numbers/*real 2.79 ± 0 ns 2.79 ± 0.001 ns 1 ± 0.00036
Quantity/with_numbers/^int 8.68 ± 2.2 ns 8.67 ± 2.2 ns 1 ± 0.35
Quantity/with_numbers/^int * real 9.29 ± 2.2 ns 9.29 ± 2.2 ns 1 ± 0.33
Quantity/with_quantity/+y 4.35 ± 0.01 ns 4.35 ± 0 ns 1 ± 0.0023
Quantity/with_quantity//y 3.42 ± 0.01 ns 3.41 ± 0.01 ns 1 ± 0.0042
Quantity/with_self/dimension 3.11 ± 0.001 ns 3.1 ± 0.01 ns 1 ± 0.0032
Quantity/with_self/inv 3.11 ± 0.001 ns 3.11 ± 0.001 ns 1 ± 0.00046
Quantity/with_self/ustrip 3.1 ± 0.01 ns 3.1 ± 0.01 ns 1 ± 0.0046
QuantityArray/broadcasting/multi_array_of_quantities 0.0904 ± 0.001 ms 0.0908 ± 0.0011 ms 0.996 ± 0.017
QuantityArray/broadcasting/multi_normal_array 0.0498 ± 0.00026 ms 0.0498 ± 0.00028 ms 1 ± 0.0077
QuantityArray/broadcasting/multi_quantity_array 0.0622 ± 0.00026 ms 0.0622 ± 0.0092 ms 1 ± 0.15
QuantityArray/broadcasting/x^2_array_of_quantities 14.7 ± 4.4 μs 16.8 ± 4.2 μs 0.88 ± 0.34
QuantityArray/broadcasting/x^2_normal_array 2.29 ± 2.5 μs 2.51 ± 2.3 μs 0.913 ± 1.3
QuantityArray/broadcasting/x^2_quantity_array 3.55 ± 0.34 μs 3.65 ± 0.57 μs 0.973 ± 0.18
QuantityArray/broadcasting/x^4_array_of_quantities 0.0843 ± 0.0009 ms 0.0846 ± 0.00083 ms 0.997 ± 0.014
QuantityArray/broadcasting/x^4_normal_array 0.0497 ± 0.00016 ms 0.0497 ± 0.00017 ms 1 ± 0.0047
QuantityArray/broadcasting/x^4_quantity_array 0.0498 ± 0.0031 ms 0.0468 ± 0.0002 ms 1.06 ± 0.067
time_to_load 0.233 ± 0.00069 s 0.228 ± 0.0018 s 1.02 ± 0.0086
Memory benchmarks
main 0148cb2... main / 0148cb2...
Quantity/creation/Quantity(x) 0 allocs: 0 B 0 allocs: 0 B
Quantity/creation/Quantity(x, length=y) 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_numbers/*real 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_numbers/^int 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_numbers/^int * real 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_quantity/+y 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_quantity//y 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_self/dimension 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_self/inv 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_self/ustrip 0 allocs: 0 B 0 allocs: 0 B
QuantityArray/broadcasting/multi_array_of_quantities 3 allocs: 0.382 MB 3 allocs: 0.382 MB 1
QuantityArray/broadcasting/multi_normal_array 3 allocs: 0.0764 MB 3 allocs: 0.0764 MB 1
QuantityArray/broadcasting/multi_quantity_array 3 allocs: 0.0764 MB 3 allocs: 0.0764 MB 1
QuantityArray/broadcasting/x^2_array_of_quantities 3 allocs: 0.382 MB 3 allocs: 0.382 MB 1
QuantityArray/broadcasting/x^2_normal_array 3 allocs: 0.0764 MB 3 allocs: 0.0764 MB 1
QuantityArray/broadcasting/x^2_quantity_array 3 allocs: 0.0764 MB 3 allocs: 0.0764 MB 1
QuantityArray/broadcasting/x^4_array_of_quantities 3 allocs: 0.382 MB 3 allocs: 0.382 MB 1
QuantityArray/broadcasting/x^4_normal_array 3 allocs: 0.0764 MB 3 allocs: 0.0764 MB 1
QuantityArray/broadcasting/x^4_quantity_array 3 allocs: 0.0764 MB 3 allocs: 0.0764 MB 1
time_to_load 0.159 k allocs: 11.2 kB 0.159 k allocs: 11.2 kB 1

@icweaver
Copy link
Contributor

Thanks Miles, love the simplifications here! Should this bit of the README also be updated now?

3-element QuantityArray(::Vector{Float64}, ::Quantity{Float64, Dimensions{FixedRational{Int32, 25200}}}):

- 3-element QuantityArray(::Vector{Float64}, ::Quantity{Float64, Dimensions{FixedRational{Int32, 25200}}}):
+ 3-element QuantityArray(::Vector{Float64}, ::Quantity{Float64, Dimensions{FRInt32}}):

I also did some reading on why the type alias printing tests are failing, and my understanding is that this is actually by design? I'm still getting familiar with TestItems, but are things failing because it is creating its own module, leading to the fully qualified types we're seeing in CI, but not interactively?

@MilesCranmer
Copy link
Member Author

I don't think so b/c these ones are normal @testset and FRInt32 is in the namespace... Weird

@MilesCranmer
Copy link
Member Author

And thx, good catch

@MilesCranmer
Copy link
Member Author

This is what shows up in the REPL:

image

Idk. Maybe the testset turns this off somehow... But even doing string(FRInt32) works correctly elsewhere.

Co-authored-by: Ian Weaver <[email protected]>
@MilesCranmer
Copy link
Member Author

Oh wait. You're totally right!!! My bad. Just saw this behavior:

julia> module A
       using DynamicQuantities
       f() = println(FRInt32)
       end
Main.A

julia> A.f()
DynamicQuantities.FRInt32

julia> using DynamicQuantities

julia> A.f()
FRInt32

Which is ... sorta weird. But I guess means the tests need to accommodate.

@codecov
Copy link

codecov bot commented Sep 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.14%. Comparing base (b7ec886) to head (0148cb2).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #191   +/-   ##
=======================================
  Coverage   99.14%   99.14%           
=======================================
  Files          21       21           
  Lines        1292     1292           
=======================================
  Hits         1281     1281           
  Misses         11       11           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MilesCranmer MilesCranmer merged commit 31cac01 into main Sep 13, 2025
8 checks passed
@MilesCranmer MilesCranmer deleted the fixed-rational-constant branch September 13, 2025 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants