Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: add methods for automatic unit conversion for SymbolicDimensions #63

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MilesCranmer
Copy link
Member

cc @gaurav-arya

This makes it so that you can add 1.5us"km" with 1500us"m" and there won't be a dimension error. It will choose to convert to the leftmost dimension.

I'm not sure if that's the best thing to do though (maybe we should force users to stay in the same dimensions), so any thoughts appreciated!

e.g., this would make your chemistry example possible with symbolic dimensions throughout. You could add J and eV and not have it be converted to SI units.

@github-actions
Copy link

Benchmark Results

main 1590e79... t[main]/t[1590e79...]
Quantity/creation/Quantity(x) 4.4 ± 0.3 ns 3.6 ± 0.3 ns 1.22
Quantity/creation/Quantity(x, length=y) 4.5 ± 0.1 ns 4 ± 0.3 ns 1.12
Quantity/with_numbers/*real 3.8 ± 0.3 ns 3.8 ± 0.3 ns 1
Quantity/with_numbers/^int 13.7 ± 4.8 ns 12.7 ± 4.1 ns 1.08
Quantity/with_numbers/^int * real 14.1 ± 5.2 ns 14.1 ± 4.3 ns 1
Quantity/with_quantity/+y 7.6 ± 0.6 ns 9.3 ± 0.1 ns 0.817
Quantity/with_quantity//y 4.5 ± 0.1 ns 4.5 ± 0.4 ns 1
Quantity/with_self/dimension 1.9 ± 0.1 ns 1.9 ± 0.1 ns 1
Quantity/with_self/inv 4.5 ± 0.1 ns 4.1 ± 0.3 ns 1.1
Quantity/with_self/ustrip 2 ± 0.1 ns 1.9 ± 0.1 ns 1.05
QuantityArray/broadcasting/multi_array_of_quantities 0.269 ± 0.023 ms 0.268 ± 0.046 ms 1
QuantityArray/broadcasting/multi_normal_array 0.0902 ± 0.0071 ms 0.0927 ± 0.0074 ms 0.973
QuantityArray/broadcasting/multi_quantity_array 0.304 ± 0.024 ms 0.305 ± 0.023 ms 0.998
QuantityArray/broadcasting/x^2_array_of_quantities 0.0493 ± 0.0047 ms 0.0465 ± 0.0037 ms 1.06
QuantityArray/broadcasting/x^2_normal_array 10.1 ± 1.9 μs 10 ± 1.8 μs 1.01
QuantityArray/broadcasting/x^2_quantity_array 11.4 ± 1.1 μs 11.5 ± 1 μs 0.991
QuantityArray/broadcasting/x^4_array_of_quantities 0.16 ± 0.013 ms 0.158 ± 0.0046 ms 1.02
QuantityArray/broadcasting/x^4_normal_array 0.0818 ± 0.0068 ms 0.0818 ± 0.0062 ms 1
QuantityArray/broadcasting/x^4_quantity_array 0.123 ± 0.0096 ms 0.114 ± 0.013 ms 1.08
time_to_load 0.195 ± 0.00064 s 0.196 ± 0.00077 s 0.993

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 MilesCranmer changed the title WIP: add methods for soft promotion WIP: add methods for overriding dimensional analysis Oct 22, 2023
@MilesCranmer MilesCranmer changed the title WIP: add methods for overriding dimensional analysis WIP: add methods for automatic unit conversion for SymbolicDimensions Oct 22, 2023
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.

None yet

1 participant