Skip to content

Commit 88e7e88

Browse files
committed
Add example of broadcasting atvalue over an array.
1 parent 0af8d8b commit 88e7e88

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ And data, a 1-element Array{Float64,1}:
116116
6.14454
117117
```
118118

119+
You can even index by multiple values by broadcasting `atvalue` over an array:
120+
121+
```julia
122+
julia> A[atvalue.([2.5e-5s, 75.0µs])]
123+
2-dimensional AxisArray{Float64,2,...} with axes:
124+
:time, Quantity{Float64, Dimensions:{𝐓}, Units:{s}}[2.5e-5 s, 7.5e-5 s]
125+
:chan, Symbol[:c1, :c2]
126+
And data, a 2×2 Array{Float64,2}:
127+
6.14454 12.2891
128+
1.37825 2.75649
129+
```
130+
119131
Sometimes, though, what we're really interested in is a window of time about a
120132
specific index. One of the operations above (looking for values in the window from 40µs
121133
to 220µs) might be more clearly expressed as a symmetrical window about a

docs/src/index.md

+12
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,18 @@ And data, a 1-element Array{Float64,1}:
137137
6.14454
138138
```
139139

140+
You can even index by multiple values by broadcasting `atvalue` over an array:
141+
142+
```jldoctest
143+
julia> A[atvalue.([2.5e-5s, 75.0µs])]
144+
2-dimensional AxisArray{Float64,2,...} with axes:
145+
:time, Quantity{Float64, Dimensions:{𝐓}, Units:{s}}[2.5e-5 s, 7.5e-5 s]
146+
:chan, Symbol[:c1, :c2]
147+
And data, a 2×2 Array{Float64,2}:
148+
6.14454 12.2891
149+
1.37825 2.75649
150+
```
151+
140152
Sometimes, though, what we're really interested in is a window of time about a
141153
specific index. One of the operations above (looking for values in the window from 40µs
142154
to 220µs) might be more clearly expressed as a symmetrical window about a

0 commit comments

Comments
 (0)