Starting a new session solved the issue
TIL: If it really seems like it should work, give it a try in a new session.
Original post:
In:
https://discourse.julialang.org/t/read-binary-data-of-arbitrary-dims-and-type/28560
I got help on reading binary data (thanks!), but stumbled into a secondary problem.
Using julia 1.1.1 1.0.4
Please note: code examples are copied by hand. I can’t have web access and julia one the same machine. Mistakes are possible.
function read_dat(filename, dims, T)
img = Array{T}(undef, (dims))
open(filename)
do io
read!(io, img)
end
end
#Calling it with this works fine:
data = read_dat("myfilename.img", (251, 260), Float32)
# But trying to use variables for dims does not:
bands=250; lines=260; samples=440;
fn = “myfile.img”;
dtype = Float32;
data = read_dat(fn, (bands,lines,samples), dtype)
fn and dtype pass ok, as does just a single variable for dims, but trying to pass all 3 for dims results in
no method matching Array{Float32,N} where N(::UndefInitializer, :: Tuple{String,String,String})
I don’t understand the error message and didn’t find anything in the docs to decode it.
In use, dims could be 1,2, or 3 values.