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_p3OZNA`
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
   Installed ConstructionBase ─ v1.5.8
   Installed GPUArraysCore ──── v0.1.6
   Installed StructArrays ───── v0.6.18
   Installed StaticArraysCore ─ v1.4.3
   Installed Adapt ──────────── v4.2.0
   Installed StaticArrays ───── v1.9.13
    Updating `/tmp/jl_p3OZNA/Project.toml`
  [09ab397b] + StructArrays v0.6.18
    Updating `/tmp/jl_p3OZNA/Manifest.toml`
  [79e6a3ab] + Adapt v4.2.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.0
  [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.0
  [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...
CompilerSupportLibraries_jll
Adapt
StaticArraysCore
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
107 μs
👀 Reading hidden code
Enter cell code...
70.1 μs
2×2 StructArray(::Matrix{Float64}, ::Matrix{Float64}) with eltype ComplexF64:
 0.253725+0.493641im   0.949906+0.240513im
 0.973359+0.661753im  0.0542274+0.911666im
👀 Reading hidden code
s = StructArray{ComplexF64}((rand(2,2), rand(2,2)))
92.1 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.6 ms
Column1Column2Column3Column4Column5Column6Column7Column8more
Float64Float64Float64Float64Float64Float64Float64Float64
1
0.0224104
0.626141
0.705631
0.0277181
0.166051
0.251483
0.969934
0.793859
2
0.863897
0.0178973
0.190555
0.988322
0.323614
0.992751
0.949578
0.638692
3
0.412779
0.01478
0.823216
0.735826
0.219483
0.812801
0.627227
0.783774
4
0.217587
0.205335
0.706023
0.861281
0.56263
0.104691
0.491328
0.341069
5
0.0808613
0.382978
0.0301538
0.113368
0.746388
0.806647
0.668848
0.183771
6
0.0154356
0.0725448
0.453642
0.675574
0.817269
0.511067
0.753238
0.101485
7
0.225465
0.175325
0.615306
0.873884
0.234308
0.0725932
0.365552
0.31235
8
0.145574
0.597777
0.911488
0.21148
0.32492
0.704629
0.867326
0.78181
9
0.462694
0.209176
0.419049
0.453084
0.534379
0.94828
0.520784
0.115243
10
0.369344
0.35821
0.242618
0.103198
0.912522
0.833921
0.48052
0.847757
more
t = Tables.table(rand(400,400))
👀 Reading hidden code
83.1 ms
true
hasmethod(view, (typeof([1,2,3]), typeof(1:3)))
👀 Reading hidden code
44.7 μs
1:100
a = 1:100
👀 Reading hidden code
13.6 μ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/8p03y/src/Tables.jl:185

getindex(::Union{Tables.AbstractColumns, Tables.AbstractRow}, ::Int64) at ~/.julia/packages/Tables/8p03y/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.6 μ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