JuliaAstro / FITSIO.jl

Flexible Image Transport System (FITS) file support for Julia
http://juliaastro.org/FITSIO.jl/
MIT License
55 stars 29 forks source link

fix warnings from Julia 0.5 #53

Closed jeff-regier closed 7 years ago

jeff-regier commented 7 years ago

Hi @kbarbary -- This fixes the vast majority of warnings from Julia 0.5, without breaking any backward compatibility, I think.

jeff-regier commented 7 years ago

I still see a few warnings when I run the tests.

julia> Pkg.test("FITSIO")
INFO: Testing FITSIO
WARNING: Method definition cfitsio_typecode(Type{Int64}) in module Libcfitsio at /home/jeff/.julia/v0.5/FITSIO/src/libcfitsio.jl:164 overwritten at /home/jeff/.julia/v0.5/FITSIO/src/libcfitsio.jl:164.
WARNING: Base.ASCIIString is deprecated, use String instead.
  likely near /home/jeff/.julia/v0.5/FITSIO/src/libcfitsio.jl:356
WARNING: Base.ASCIIString is deprecated, use String instead.
  likely near /home/jeff/.julia/v0.5/FITSIO/src/libcfitsio.jl:356

WARNING: deprecated syntax "[a=>b for (a,b) in c]".
Use "Dict(a=>b for (a,b) in c)" instead.
WARNING: Base.ASCIIString is deprecated, use String instead.
  likely near /home/jeff/.julia/v0.5/FITSIO/test/runtests.jl:118
All tests passed.
INFO: FITSIO tests passed

If you can see how to fix these, please let me know.

kbarbary commented 7 years ago

Did this fix all the warnings?

jeff-regier commented 7 years ago

Two warnings left:

WARNING: Method definition cfitsio_typecode(Type{Int64}) in module Libcfitsio at /home/jeff/.julia/v0.5/FITSIO/src/libcfitsio.jl:164 overwritten at /home/jeff/.julia/v0.5/FITSIO/src/libcfitsio.jl:164.

and

WARNING: deprecated syntax "[a=>b for (a,b) in c]".
Use "Dict(a=>b for (a,b) in c)" instead.
jeff-regier commented 7 years ago

The second warning is easily fixed by replacing line 114 with

        map = Dict(keys[i] => i for i in 1:length(keys))

but that breaks compatibility with Julia 0.4. I don't see a macro in Compat.jl that solves the problem

kbarbary commented 7 years ago

Could just remove the comprehension: initialize an empty Dict{String, Int} and fill it in a loop.

The other warning is because Clong is Int64 on your system. Unrelated to Julia version changes, but maybe there's better method redefinition warnings on 0.5. You could try fixing this with a conditional (only define cfitsio_typecode(Type{Clong}) if Clong is not Int64) or it can be done in a separate PR.

jeff-regier commented 7 years ago

OK, I think this is done now. I'll leave the method definition for another PR.

kbarbary commented 7 years ago

Thanks Jeff, looks good.