I am comparing two arrays that contain both numbers and strings using
FactCheck and got an error
Error :: (line:-1)
data_code => roughly(data_ref,atol=1.0e-13)
MethodError: `isapprox` has no method matching
isapprox(::SubString{ASCIIString}, ::SubString{ASCIIString})
so I defined a new method:
import Base.isapprox
# generic fallback
function isapprox(a::SubString{ASCIIString}, b::SubString{ASCIIString})
return a == b
end
and now I get the error:
Error :: (line:-1)
data_code => roughly(data_ref,atol=1.0e-13)
MethodError: `isapprox` has no method matching
isapprox(::SubString{ASCIIString}, ::SubString{ASCIIString})
Closest candidates are:
isapprox(::SubString{ASCIIString}, ::SubString{ASCIIString})
I get a similar error if I don't restrict the argument types of isapprox:
Error :: (line:-1)
data_code => roughly(data_ref,atol=1.0e-13)
MethodError: `isapprox` has no method matching
isapprox(::SubString{ASCIIString}, ::SubString{ASCIIString})
Closest candidates are:
isapprox(::Any, ::Any)
In all cases the backtrace is:
in anonymous at no file:46
in anonymous at /users/creanj/.julia/v0.4/FactCheck/src/FactCheck.jl:140
in anonymous at /users/creanj/.julia/v0.4/FactCheck/src/FactCheck.jl:142
in do_fact at /users/creanj/.julia/v0.4/FactCheck/src/FactCheck.jl:201
in anonymous at
/users/creanj/.julia/v0.4/PumiInterface/test/pdepumiinterface.jl:142
in facts at /users/creanj/.julia/v0.4/FactCheck/src/FactCheck.jl:315
in include at ./boot.jl:253
in include_from_node1 at ./loading.jl:133
in include at ./boot.jl:253
in include_from_node1 at loading.jl:133
in process_options at ./client.jl:312
in _start at ./client.jl:412
Why does isapprox(::SubString{ASCIIString}, ::SubString{ASCIIString}) not
match the fallback I defined?
Here is a minimal example (although it generates a slightly different error:
MethodError: `isapprox` has no method matching isapprox(::ASCIIString,
::ASCIIString)
):
using FactCheck
import Base.isapprox
function isapprox(a, b)
return a == b
end
facts("----- A non working example -----") do
a = [1.5, "abc"]
@fact a => roughly(a, atol=1e-14)
end
Jared Crean