SymbolicML / DynamicQuantities.jl

Efficient and type-stable physical quantities in Julia
https://symbolicml.org/DynamicQuantities.jl/dev/
Apache License 2.0
132 stars 17 forks source link

Give `Dimensions` a type parameter. #14

Closed oscardssmith closed 1 year ago

MilesCranmer commented 1 year ago

Okay I think I got it working. Could you add some unittests for custom Dimensions{R} types? Maybe the Int8/6 idea that you mentioned?

MilesCranmer commented 1 year ago

Not sure why coveralls is failing but otherwise the tests are passing.

MilesCranmer commented 1 year ago

Should probably test when and where type promotion happens, and if it gives expected behavior or not.

github-actions[bot] commented 1 year ago

Benchmark Results

main 5d79a34ab77734... t[main]/t[5d79a34ab77734...]
creation/Quantity(x) 5.6 ± 0.5 ns 4.3 ± 0.2 ns 1.3
creation/Quantity(x, length=y) 5.1 ± 0.2 ns 4.6 ± 0.2 ns 1.11
time_to_load 0.176 ± 0.0069 s 0.0922 ± 0.01 s 1.91
with_numbers/*real 4.5 ± 0.3 ns 4.3 ± 0.1 ns 1.05
with_numbers/^int 0.0335 ± 0.0036 μs 0.247 ± 0.026 μs 0.135
with_numbers/^int * real 0.0344 ± 0.0039 μs 0.248 ± 0.024 μs 0.139
with_quantity/+y 22.7 ± 1.7 ns 0.333 ± 0.034 μs 0.0682
with_quantity//y 23 ± 1.7 ns 0.34 ± 0.039 μs 0.0677
with_self/dimension 1.8 ± 0.1 ns 2 ± 0.1 ns 0.9
with_self/inv 20.8 ± 1.6 ns 9.7 ± 0.3 ns 2.14
with_self/ustrip 1.9 ± 0.1 ns 2 ± 0.1 ns 0.95

Benchmark Plots

A plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).

MilesCranmer commented 1 year ago

Okay I think it's ready. Could you review my changes @oscardssmith ?

oscardssmith commented 1 year ago

LGTM