Skip to content
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

Method Error with iscontiguous when nccreate is called #80

Open
wrongkindofdoctor opened this issue Dec 6, 2018 · 4 comments
Open

Method Error with iscontiguous when nccreate is called #80

wrongkindofdoctor opened this issue Dec 6, 2018 · 4 comments

Comments

@wrongkindofdoctor
Copy link

Running the netcdf example using dictionaries to replace the deprecated curly brackets with Julia V1.0.2 produces the error
ERROR: MethodError: no method matching iscontiguous(::UnitRange{Int64})
This error occurs wit h Julia 1.0.2 on Rhel7, MacOS Mojave, and Windows 10 OS's

Script:

using NetCDF
filename   = "myfile.nc"
varname    = "var1"
attribs = Dict("units" => "mm/d", "data_min" => 0.0, "data_max" => 87.0)
nccreate(filename, varname, "x1", 11:20, "t", 20, Dict("units"=>"s"), atts=attribs)

Result:

ERROR: MethodError: no method matching iscontiguous(::UnitRange{Int64})
Closest candidates are:
  iscontiguous(::SubArray) at subarray.jl:286
  iscontiguous(::Type{#s57} where #s57<:(SubArray{T,N,P,I,true} where I<:Tuple{AbstractUnitRange,Vararg{Any,N} where N} where P where N where T)) at subarray.jl:288
  iscontiguous(::Type{#s57} where #s57<:SubArray) at subarray.jl:287
Stacktrace:
 [1] #putvar#31(::Array{Int64,1}, ::Array{Int64,1}, ::Function, ::NcVar{Int64,1,10}, ::UnitRange{Int64}) at /home/Jessica.Liptak/.julia/packages/NetCDF/61OwG/src/NetCDF.jl:437
 [2] (::getfield(NetCDF, Symbol("#kw##putvar")))(::NamedTuple{(:start, :count),Tuple{Array{Int64,1},Array{Int64,1}}}, ::typeof(NetCDF.putvar), ::NcVar{Int64,1,10}, ::UnitRange{Int64}) at ./none:0
 [3] #putvar#30(::Array{Int64,1}, ::Array{Int64,1}, ::Function, ::NcFile, ::String, ::UnitRange{Int64}) at /home/Jessica.Liptak/.julia/packages/NetCDF/61OwG/src/NetCDF.jl:421
 [4] putvar(::NcFile, ::String, ::UnitRange{Int64}) at /home/Jessica.Liptak/.julia/packages/NetCDF/61OwG/src/NetCDF.jl:421
 [5] #create#38(::Dict{Any,Any}, ::UInt16, ::Function, ::String, ::Array{NcVar,1}) at /home/Jessica.Liptak/.julia/packages/NetCDF/61OwG/src/NetCDF.jl:634
 [6] #create at ./none:0 [inlined]
 [7] #create#39(::Dict{Any,Any}, ::UInt16, ::Function, ::String, ::NcVar{Float64,2,6}) at /home/Jessica.Liptak/.julia/packages/NetCDF/61OwG/src/NetCDF.jl:641
 [8] (::getfield(NetCDF, Symbol("#kw##create")))(::NamedTuple{(:gatts, :mode),Tuple{Dict{Any,Any},UInt16}}, ::typeof(NetCDF.create), ::String, ::NcVar{Float64,2,6}) at ./none:0
 [9] #nccreate#51(::Dict{String,Any}, ::Dict{Any,Any}, ::Int64, ::Int64, ::UInt16, ::Tuple{Int64}, ::Function, ::String, ::String, ::String, ::Vararg{Any,N} where N) at /home/Jessica.Liptak/.julia/packages/NetCDF/61OwG/src/NetCDF.jl:920
 [10] (::getfield(NetCDF, Symbol("#kw##nccreate")))(::NamedTuple{(:atts,),Tuple{Dict{String,Any}}}, ::typeof(nccreate), ::String, ::String, ::String, ::Vararg{Any,N} where N) at ./none:0
 [11] top-level scope at none:0
@jarlela
Copy link
Contributor

jarlela commented Dec 7, 2018

The problem here is the range 11:20, according to the function documentation this should be an array or a length (scalar). It should work if you replace the range by collect(11:20).

@visr
Copy link
Member

visr commented Dec 7, 2018

Would be nice if this could be made to work with ranges, don't see why in this case it shouldn't.

And would be good to update the README examples to julia 1.0 syntax as well.

@wrongkindofdoctor
Copy link
Author

Replacing the range with collect fixed the issue, and I was able to run the entire quickstart example. Thanks for your help!

@visr
Copy link
Member

visr commented Jan 9, 2019

@wrongkindofdoctor I'm reopening. Glad that using collect as a workaround helped, but I'll reopen so we don't forget to fix it properly sometime.

The README syntax is now updated in #82.

@visr visr reopened this Jan 9, 2019
visr added a commit that referenced this issue Jan 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants