-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when writing Array{Float64, 0}
#197
Comments
Thanks a lot for the very detailed bug report! I noticed that also in Base julia complains a bit about this: b = dropdims([1], dims=(1,))
temp = [1.,2.,3.]
temp[1] = b # ERROR: MethodError: Cannot `convert` an object of type Array{Float64, 0} to an object of type Float64 But the following works in Julia: b = dropdims([1], dims=(1,))
temp = [0.,2.,3.]
temp[1:1] = b # ok In the master version (but not in v0.12.11) the following now work too with NCDatasets, using NCDatasets
b = dropdims([1.], dims=(1,))
isfile("/tmp/test.nc") || rm("/tmp/test.nc")
ds = NCDataset("/tmp/test.nc","c")
time = defDim(ds,"time",Inf) # works also for fixed size arrays
v = defVar(ds,"temp",Float32,("time",))
ds["temp"][1:1] = b
close(ds) Are you fine to use |
Thanks for the fix! I think this solution will work out (let's see how the discussion on the relevant PR (CliMA/Oceananigans.jl#2865) goes to be sure...)
Thank you! But I can't take the merit there. I'm only a very minor contributor :) |
I am closing the issue; feel free to re-open if there are still some difference between Base.Array and NCDatasets regarding the 0-D arrays. |
Describe the bug
I get an error when trying to write a type
Array{Float64, 0}
to an index of a variable with an unbounded dimension. The error is also reported in CliMA/Oceananigans.jl#2857To Reproduce
In believe this comes from the function call
T(data)
in this line:NCDatasets.jl/src/variable.jl
Line 308 in 69eda01
Expected behavior
I expected the Array to be successfully writen to the NetCDF. For reference, this MWE works, which shows that the issue comes when using an unbounded dimension:
Environment
using Pkg; Pkg.status(mode=PKGMODE_MANIFEST)
: https://pastebin.com/gfbdcRu1Full output
I was wondering if this is something that should be dealt with on the NCDatasets side, or if this is by design and we should deal with it on the Oceananigans side.
Thanks
The text was updated successfully, but these errors were encountered: