Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
392701a
first pass
icweaver May 31, 2025
2feea5c
added some usage docs
icweaver Jun 3, 2025
b84257e
added ref link between Home and Examples pages
icweaver Jul 12, 2025
2c27270
updated QuantityArray docstring to include convenience method
icweaver Jul 12, 2025
f1b4706
remove accidentally added file
icweaver Jul 14, 2025
5a59406
removed ref link
icweaver Jul 14, 2025
2e72c26
Merge branch 'main' into quantityarray-construction
icweaver Jul 14, 2025
f08023b
Update README.md
icweaver Jul 14, 2025
c15675f
Update README.md
icweaver Jul 14, 2025
12b20d2
switched to relative header link
icweaver Jul 15, 2025
096ca12
fix remaining ambiguities
icweaver Jul 29, 2025
52a54fd
relax Dates compat
icweaver Jul 29, 2025
8b00bb0
remove accidentally added .gitignore file
icweaver Jul 29, 2025
1e6b410
put back original .gitignore
icweaver Jul 29, 2025
0c8b97a
revert doc build-specific stuff from Abhro's PR
icweaver Aug 2, 2025
b27ec64
remove Dates.jl-specific stuff
icweaver Aug 2, 2025
4c88d04
Merge branch 'main' into quantityarray-construction
icweaver Aug 3, 2025
87e8b1f
Merge branch 'JuliaPhysics:main' into quantityarray-construction
icweaver Aug 3, 2025
046b8d4
use tighter subtyping to avoid method ambiguity with Dates.jl
icweaver Aug 5, 2025
0d3fcd8
reorg + some tests
icweaver Aug 6, 2025
3b185a9
Merge branch 'main' into quantityarray-construction
icweaver Aug 6, 2025
227ece9
reorg
icweaver Aug 6, 2025
51270a2
Merge branch 'main' into quantityarray-construction
icweaver Aug 12, 2025
768972b
Merge branch 'main' into quantityarray-construction
icweaver Aug 22, 2025
cdfce08
updated examples
icweaver Aug 29, 2025
42d62b4
cleanup
icweaver Aug 30, 2025
e110662
more LA tests
icweaver Aug 30, 2025
8f34f3b
put back accidentally deleted coverage.jl
icweaver Aug 30, 2025
7869b73
extra test highlighted by codecov
icweaver Sep 1, 2025
3c97dab
simplify usage examples
icweaver Sep 1, 2025
017d5d4
simplified type checks
icweaver Sep 1, 2025
97ec277
Merge branch 'main' into quantityarray-construction
icweaver Sep 11, 2025
7ae45ef
tweak README example
MilesCranmer Sep 11, 2025
c475043
unused variable
MilesCranmer Sep 11, 2025
7dab92a
reduce docstring
MilesCranmer Sep 11, 2025
01b9e5e
use nicer syntax elsewhere
MilesCranmer Sep 11, 2025
22767a5
fix: nested QuantityArray issue
MilesCranmer Sep 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ julia> ustrip(ua"degC", 295.15u"K")
22.0
```

### Arrays
### [Arrays](@id home_arrays)

For working with an array of quantities that have the same dimensions,
you can use a `QuantityArray`:
Expand Down Expand Up @@ -364,6 +364,22 @@ julia> @btime $f.(qa) setup=(xa = randn(100000) .* u"km/s"; qa = QuantityArray(x

So we can see the `QuantityArray` version saves on both time and memory.

By default, DynamicQuantities will create a `QuantityArray` from an `AbstractArray`, similarly to how a `Quantity` is created from a scalar in the [Usage](@ref) examples:

```@repl quantity-array
using DynamicQuantities # hide

x = [0.3, 0.4, 0.5]u"km/s"

y = (42:45) * u"kg"
```

This can be overridden to produce a vector of `Quantity`s by explicitly broadcasting the unit:

```@repl quantity-array
z = [0.3, 0.4, 0.5] .* u"km/s"
```

### Unitful

DynamicQuantities allows you to convert back and forth from Unitful.jl:
Expand Down
3 changes: 3 additions & 0 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ the same dimension) by passing an array and a single quantity:

```julia
x = QuantityArray(randn(32), u"km/s")
# or x = randn(32)u"km/s"
```

or, by passing an array of individual quantities:
Expand Down Expand Up @@ -281,6 +282,8 @@ f_square(v) = v^2 * 1.5 - v^2
println("Applying function to y_q: ", sum(f_square.(y_q)))
```

See [Home > Arrays](@ref home_arrays) for more.

### Fill

We can also make `QuantityArray` using `fill`:
Expand Down
Loading