Skip to content

Commit 032327a

Browse files
goretkinc42f
authored andcommitted
Make README examples run on on v1 (#171)
1 parent 316abc8 commit 032327a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ path to whatever the new name will be.
3838
## Example of currently-implemented behavior:
3939

4040
```julia
41-
julia> Pkg.add("AxisArrays")
41+
julia> using Pkg; Pkg.add("AxisArrays")
4242
julia> using AxisArrays, Unitful
4343
julia> import Unitful: s, ms, µs
44+
julia> using Random: MersenneTwister
4445

4546
julia> rng = MersenneTwister(123) # Seed a random number generator for repeatable examples
4647
julia> fs = 40000 # Generate a 40kHz noisy signal, with spike-like stuff added for testing
@@ -237,8 +238,8 @@ headers.
237238

238239
```julia
239240
B = AxisArray(reshape(1:15, 5, 3), .1:.1:0.5, [:a, :b, :c])
240-
B[Axis{:row}(Interval(.2,.4))] # restrict the AxisArray along the time axis
241-
B[Interval(0.,.3), [:a, :c]] # select an interval and two of the columns
241+
B[Axis{:row}(0.2..0.4)] # restrict the AxisArray along the time axis
242+
B[0.0..0.3, [:a, :c]] # select an interval and two of the columns
242243
```
243244

244245
User-defined axis types can be added along with custom indexing
@@ -248,7 +249,8 @@ behaviors.
248249
```julia
249250
B = AxisArray(randn(100,100,100), :x, :y, :z)
250251
Itotal = sumz = 0.0
251-
for iter in CartesianRange(indices(B)) # traverses in storage order for cache efficiency
252+
for iter in CartesianIndices(Base.axes(B)) # traverses in storage order for cache efficiency
253+
global Itotal, sumz
252254
I = B[iter] # intensity in a single voxel
253255
Itotal += I
254256
sumz += I * iter[axisdim(B, Axis{:z})] # axisdim "looks up" the z dimension

0 commit comments

Comments
 (0)