MethodError: no method matching imagesc(::Array{Float64,2}, ::Nothing, ::Nothing, ::Nothing)

#1

Hey. I’m trying to work on julia’s EchogramImages library.

This is my error:
Error During Test at /home/pranjaliraturi/EchogramImages.jl/test/runtests.jl:6
Got exception outside of a @test
MethodError: no method matching imagesc(::Array{Float64,2}, ::Nothing, ::Nothing, ::Nothing)
Closest candidates are:
imagesc(::Any; vmin, vmax, cmap, size) at /home/pranjaliraturi/.julia/packages/EchogramImages/rVj6X/src/EchogramImages.jl:38
Stacktrace:
[1] top-level scope at /home/pranjaliraturi/EchogramImages.jl/test/runtests.jl:8
[2] top-level scope at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Test/src/Test.jl:1083
[3] top-level scope at /home/pranjaliraturi/EchogramImages.jl/test/runtests.jl:7
[4] include at ./boot.jl:326 [inlined]
[5] include_relative(::Module, ::String) at ./loading.jl:1038
[6] include(::Module, ::String) at ./sysimg.jl:29
[7] include(::String) at ./client.jl:403
[8] top-level scope at none:0
[9] eval(::Module, ::Any) at ./boot.jl:328
[10] eval_user_input(::Any, ::REPL.REPLBackend) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:85
[11] macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:117 [inlined]
[12] (::getfield(REPL, Symbol("##26#27")){REPL.REPLBackend})() at ./task.jl:259

The following is my code:
using EchogramImages
using Test
using EchogramColorSchemes
using ColorSchemes

a = rand(100,100)
img = imagesc(a, nothing, nothing, nothing)
m,n = size(img)
@test m == 480
@test n == 640
@test cmap == cmap.colors
@test typeof(vmin) == AbstractFloat
@test typeof(vmax) == AbstractFloat
@test vmin <= @. img <= vmax
.
.
.
.
.
.

This is the function that was already created:

using Images
using MappedArrays
using IndirectArrays
using EchogramColorSchemes
using ColorSchemes

export imagesc, mat2gray, equalizedbins, quantize

“”"
imagesc(A; vmin = nothing, vmax = nothing, cmap= nothing, size=(480,640))

A is any numeric array

cmap can be a list of Colors or can come from EchogramColorSchemes.jl,
ColorSchemes.jl or PerceptualColourMaps.jl. The default nothing
currently means use EK80 colours.

Set size = nothing for full resolution.

vmin and vmax are minimum and maximum values.

“”"
function imagesc(A;
vmin = nothing,
vmax = nothing,
cmap= nothing,
size=(480,640))

if cmap == nothing
    cmap = addwhite(EK80)
end

if isa(cmap,ColorScheme)
    cmap = cmap.colors
end

.
.
.
.
.

end

I’m assuming it’s because I’m passing incompatible types in the function imagesc. However I assumed the function’s prototype from the function logic and my mentor was generous enough to give me a general idea of what was going on. Please let me know what’s up and I’ll try to fix it. All the help is appreciated!!

#2

There’s a lot of badly formatted (remember to use triple backticks!) here - can you try and condense this to a minimum working example?

#3

This is my error:
Error During Test at /home/pranjaliraturi/EchogramImages.jl/test/runtests.jl:6
Got exception outside of a @test
MethodError: no method matching imagesc(::Array{Float64,2}, ::Nothing, ::Nothing, ::Nothing)
Closest candidates are:
imagesc(::Any; vmin, vmax, cmap, size) at /home/pranjaliraturi/.julia/packages/EchogramImages/rVj6X/src/EchogramImages.jl:38

The following is my code:

using EchogramImages
using Test
using EchogramColorSchemes
using ColorSchemes

a = rand(100,100)
img = imagesc(a, nothing, nothing, nothing)
m,n = size(img)
@test m == 480
@test n == 640
@test cmap == cmap.colors
@test typeof(vmin) == AbstractFloat
@test typeof(vmax) == AbstractFloat
@test vmin &lt;= @. img &lt;= vmax
.
.
.
.
.
.

This is the function that was already created:

using Images
using MappedArrays
using IndirectArrays
using EchogramColorSchemes
using ColorSchemes

export imagesc, mat2gray, equalizedbins, quantize

"""
imagesc(A; vmin = nothing, vmax = nothing, cmap= nothing, size=(480,640))

A is any numeric array

cmap can be a list of Colors or can come from EchogramColorSchemes.jl,
ColorSchemes.jl or PerceptualColourMaps.jl. The default  `nothing`
currently means use EK80 colours.

Set size = nothing for full resolution.

vmin and vmax are minimum and maximum values.

"""
function imagesc(A;
vmin = nothing,
vmax = nothing,
cmap= nothing,
size=(480,640))

if cmap == nothing
    cmap = addwhite(EK80)
end

if isa(cmap,ColorScheme)
    cmap = cmap.colors
end

.
.
.
.
end

I’m assuming it’s because I’m passing incompatible types in the function imagesc. However I assumed the function’s prototype from the function logic and my mentor was generous enough to give me a general idea of what was going on. Please let me know what’s up and I’ll try to fix it. All the help is appreciated!!

#4

imagesc uses keyword arguments. Keyword arguments require you to specify which value goes to which keyword. Since what you are passing also happens to be the default values for this function you can use the following:

img = imagesc(a)

Alternatively, with keyword arguments you can pass the arguments in by name in any order.

img = imagesc(a,cmap=nothing,vmax=nothing,vmin=nothing)

or even only some of the values

img = imagesc(a,vmax=nothing)

more documentation on keyword arguments can be found here:
https://docs.julialang.org/en/v1/manual/functions/index.html#Keyword-Arguments-1