To be able to edit code and run cells, you need to run the notebook yourself. Where would you like to run the notebook?

In the cloud (experimental)

Binder is a free, open source service that runs scientific notebooks in the cloud! It will take a while, usually 2-7 minutes to get a session.

On your computer

(Recommended if you want to store your changes.)

  1. Copy the notebook URL:
  2. Run Pluto

    (Also see: How to install Julia and Pluto)

  3. Paste URL in the Open box

Frontmatter

If you are publishing this notebook on the web, you can set the parameters below to provide HTML metadata. This is useful for search engines and social media.

Author 1
👀 Reading hidden code
begin
import Pkg
Pkg.activate(mktempdir())
Pkg.add("StructArrays")
using StructArrays, Random
end
❔
  Activating new project at `/tmp/jl_Ez8NBu`
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
   Installed GPUArraysCore ──── v0.1.6
   Installed Adapt ──────────── v4.3.0
   Installed StaticArraysCore ─ v1.4.3
   Installed ConstructionBase ─ v1.5.8
   Installed StructArrays ───── v0.6.18
   Installed StaticArrays ───── v1.9.13
    Updating `/tmp/jl_Ez8NBu/Project.toml`
  [09ab397b] + StructArrays v0.6.18
    Updating `/tmp/jl_Ez8NBu/Manifest.toml`
  [79e6a3ab] + Adapt v4.3.0
  [187b0558] + ConstructionBase v1.5.8
  [9a962f9c] + DataAPI v1.16.0
  [e2d170a0] + DataValueInterfaces v1.0.0
  [46192b85] + GPUArraysCore v0.1.6
  [82899510] + IteratorInterfaceExtensions v1.0.0
  [bac558e1] + OrderedCollections v1.8.1
  [aea7be01] + PrecompileTools v1.2.1
  [21216c6a] + Preferences v1.4.3
  [ae029012] + Requires v1.3.1
  [90137ffa] + StaticArrays v1.9.13
  [1e83bf80] + StaticArraysCore v1.4.3
  [09ab397b] + StructArrays v0.6.18
  [3783bdb8] + TableTraits v1.0.1
  [bd369af6] + Tables v1.12.1
  [56f22d72] + Artifacts
  [ade2ca70] + Dates
  [8f399da3] + Libdl
  [37e2e46d] + LinearAlgebra
  [de0858da] + Printf
  [9a3f8284] + Random
  [ea8e919c] + SHA
  [9e88b42a] + Serialization
  [2f01184e] + SparseArrays
  [10745b16] + Statistics
  [fa267f1f] + TOML
  [cf7118a7] + UUIDs
  [4ec0a83e] + Unicode
  [e66e0078] + CompilerSupportLibraries_jll
  [4536629a] + OpenBLAS_jll
  [8e850b90] + libblastrampoline_jll
Precompiling project...
StaticArraysCore
CompilerSupportLibraries_jll
Adapt
ConstructionBase
OpenBLAS_jll
GPUArraysCore
libblastrampoline_jll
StaticArrays
StructArrays
  9 dependencies successfully precompiled in 7 seconds (9 already precompiled)
11.0 s
👀 Reading hidden code
using .PlutoRunner.Tables
123 μs
👀 Reading hidden code
Enter cell code...
69.8 μs
2×2 StructArray(::Matrix{Float64}, ::Matrix{Float64}) with eltype ComplexF64:
 0.946526+0.840162im  0.595655+0.304972im
 0.720134+0.523539im  0.441624+0.0512187im
👀 Reading hidden code
s = StructArray{ComplexF64}((rand(2,2), rand(2,2)))
93.0 ms
quote
    #= /home/runner/work/disorganised-mess/disorganised-mess/tables/structarrays.jl#==#0a4e7630-2350-11eb-3617-2fab5439a1f8:1 =#
    true && (view)(a, 1:2)
end
👀 Reading hidden code
macroexpand(Main, quote @view a[1:2] end)
11.7 ms
Column1Column2Column3Column4Column5Column6Column7Column8more
Float64Float64Float64Float64Float64Float64Float64Float64
1
0.345898
0.769502
0.987182
0.000924651
0.0469787
0.29373
0.933535
0.850856
2
0.858365
0.97042
0.58203
0.883672
0.0290286
0.817726
0.323014
0.715075
3
0.770566
0.286183
0.184881
0.0550942
0.545992
0.816818
0.767041
0.598766
4
0.236827
0.566491
0.534134
0.23221
0.815773
0.0166722
0.538452
0.596023
5
0.843009
0.858437
0.0575644
0.553435
0.714758
0.350344
0.676402
0.716951
6
0.411155
0.858752
0.376943
0.388861
0.186066
0.373989
0.253708
0.0967985
7
0.469129
0.594731
0.0132636
0.633969
0.38375
0.835464
0.0605184
0.120637
8
0.718423
0.289408
0.18459
0.0504116
0.857722
0.110282
0.608406
0.713131
9
0.829159
0.0993214
0.927126
0.452375
0.205534
0.236052
0.70893
0.728086
10
0.801954
0.838399
0.876657
0.599151
0.20784
0.793329
0.666026
0.0336819
more
t = Tables.table(rand(400,400))
👀 Reading hidden code
68.2 ms
true
hasmethod(view, (typeof([1,2,3]), typeof(1:3)))
👀 Reading hidden code
44.9 μs
1:100
a = 1:100
👀 Reading hidden code
12.4 μs
Error message

MethodError: no method matching getindex(::Tables.MatrixTable{Matrix{Float64}}, ::UnitRange{Int64})

Closest candidates are:

getindex(::Union{Tables.AbstractColumns, Tables.AbstractRow}, ::Symbol) at ~/.julia/packages/Tables/cRTb7/src/Tables.jl:185

getindex(::Union{Tables.AbstractColumns, Tables.AbstractRow}, ::Int64) at ~/.julia/packages/Tables/cRTb7/src/Tables.jl:184

Stack trace

Here is what happened, the most recent locations are first:

  1. tryview(x::Tables.MatrixTable{Matrix{Float64}}, idx::UnitRange{Int64})
    		view(x, idx...)	else		getindex(x, idx...)	endend
  2. Show more...
tryview(t, 5:6)
👀 Reading hidden code
---
t[3]
👀 Reading hidden code
11.0 μs
tryview (generic function with 1 method)
function tryview(x::T, idx...) where T
if hasmethod(view, (T, typeof.(idx)...))
view(x, idx...)
else
getindex(x, idx...)
end
end
👀 Reading hidden code
728 μs