Skip to content

Ensure user-defined mutable version of dimensions always copied #45

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

Closed
wants to merge 3 commits into from

Conversation

MilesCranmer
Copy link
Member

@MilesCranmer MilesCranmer commented Sep 19, 2023

While the default Dimensions is immutable, and the mutable SymbolicDimensions (which uses a sparse array) should always create a copy anyways, the user could declare a AbstractDimensions that is mutable and does not copy itself.

Therefore this PR implements copy for a variety of operations on both QuantityArray and AbstractQuantity.

todo:

  • turn off copies for broadcasting interface

@github-actions
Copy link
Contributor

Benchmark Results

main 5679cd6... t[main]/t[5679cd6...]
Quantity/creation/Quantity(x) 3.2 ± 0.1 ns 3.2 ± 0.1 ns 1
Quantity/creation/Quantity(x, length=y) 3.7 ± 0.1 ns 3.7 ± 0.1 ns 1
Quantity/with_numbers/*real 3.2 ± 0.1 ns 3.2 ± 0.1 ns 1
Quantity/with_numbers/^int 10.1 ± 2.5 ns 10.1 ± 2.4 ns 1
Quantity/with_numbers/^int * real 10.5 ± 2.5 ns 10.5 ± 2.5 ns 1
Quantity/with_quantity/+y 6 ± 0.2 ns 5.9 ± 0.1 ns 1.02
Quantity/with_quantity//y 3.7 ± 0.1 ns 3.7 ± 0.1 ns 1
Quantity/with_self/dimension 1.6 ± 0.1 ns 1.6 ± 0.1 ns 1
Quantity/with_self/inv 3.3 ± 0.1 ns 3.3 ± 0.1 ns 1
Quantity/with_self/ustrip 1.6 ± 0.1 ns 1.6 ± 0.1 ns 1
QuantityArray/broadcasting/multi_array_of_quantities 0.198 ± 0.026 ms 0.2 ± 0.0055 ms 0.993
QuantityArray/broadcasting/multi_normal_array 0.0684 ± 0.001 ms 0.0686 ± 0.001 ms 0.997
QuantityArray/broadcasting/multi_quantity_array 0.232 ± 0.0029 ms 0.232 ± 0.0033 ms 1
QuantityArray/broadcasting/x^2_array_of_quantities 0.0415 ± 0.0033 ms 0.0498 ± 0.0035 ms 0.833
QuantityArray/broadcasting/x^2_normal_array 8.8 ± 1.1 μs 10 ± 1.1 μs 0.88
QuantityArray/broadcasting/x^2_quantity_array 10.7 ± 0.7 μs 11 ± 1.1 μs 0.973
QuantityArray/broadcasting/x^4_array_of_quantities 0.117 ± 0.0033 ms 0.122 ± 0.0043 ms 0.956
QuantityArray/broadcasting/x^4_normal_array 0.0585 ± 0.0034 ms 0.0624 ± 0.0008 ms 0.938
QuantityArray/broadcasting/x^4_quantity_array 0.0854 ± 0.0041 ms 0.0827 ± 0.004 ms 1.03
time_to_load 0.166 ± 0.00029 s 0.17 ± 0.0018 s 0.975

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
Copy link
Member Author

Superseded by #56

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.

1 participant