JuliaAstro / WCSLIB.jl

Deprecated wcslib wrapper. Use WCS.jl instead.
MIT License
1 stars 6 forks source link

ERROR: LoadError: MethodError: `convert` has no method matching convert(::Type{Ptr{UInt8}}, ::ASCIIString) #6

Open jeff-regier opened 9 years ago

jeff-regier commented 9 years ago

I get an error message when I call wcspih with Julia 0.4, from line 206 in WCSLIB.jl. There also some warnings (see below) leading up to the error, but they don't look directly related to the error. I'd appreciate help fixing the error. (Unfortunately I cannot revert to Julia 0.3.) Many thanks.

julia> using WCSLIB
WARNING: dlopen_e is deprecated, use Libdl.dlopen_e instead.
 in depwarn at ./deprecated.jl:40
 in dlopen_e at deprecated.jl:10
 in anonymous at /home/jeff/.julia/v0.4/WCSLIB/src/../deps/deps.jl:7
 in include at ./boot.jl:250
 in include_from_node1 at ./loading.jl:129
 in include at ./boot.jl:250
 in include_from_node1 at ./loading.jl:129
 in reload_path at ./loading.jl:153
 in _require at ./loading.jl:68
 in require at ./loading.jl:51

julia> # create a wcsprm struct from scratch
       w = wcsprm(2; # naxis
                  cdelt = [-0.066667, 0.066667],
                  ctype = ["RA---AIR", "DEC--AIR"],
                  crpix = [-234.75, 8.3393],
                  crval = [0., -90],
                  pv    = [pvcard(2, 1, 45.0)])

julia> header = wcshdo(w);
WARNING: c_free is deprecated, use Libc.free instead.
 in depwarn at ./deprecated.jl:40
 in c_free at deprecated.jl:10
 in wcshdo at /home/jeff/.julia/v0.4/WCSLIB/src/WCSLIB.jl:238

julia> (ws,nrejected) = wcspih(header)
ERROR: MethodError: `convert` has no method matching convert(::Type{Ptr{UInt8}}, ::ASCIIString)
This may have arisen from a call to the constructor Ptr{UInt8}(...),
since type constructors fall back to convert methods.
Closest candidates are:
  convert{T}(::Type{Ptr{T}}, ::UInt64)
  convert{T}(::Type{Ptr{T}}, ::Int64)
  convert{T}(::Type{Ptr{T}}, ::Ptr{T})
  ...
 in wcspih at /home/jeff/.julia/v0.4/WCSLIB/src/WCSLIB.jl:206
kbarbary commented 9 years ago

Duplicate of #5?

jeff-regier commented 9 years ago

Oh, yeah. Changing convert(Ptr{Uint8}, header) to pointer(header) on L206 fixed it. Thanks.

kbarbary commented 9 years ago

OK, I'll go ahead and make the fix on master.

jeff-regier commented 9 years ago

Did this change get tagged? I get the same the error message now from line 206, on a new installation of WCSLIB.jl.

jeff-regier commented 9 years ago

I get a different errors when I install WCSLIB.jl from master:

julia> Pkg.clone("https://github.com/JuliaAstro/WCSLIB.jl.git")
INFO: Cloning WCSLIB from https://github.com/JuliaAstro/WCSLIB.jl.git
INFO: Computing changes...
INFO: No packages to install, update or remove
INFO: Package database updated

julia> Pkg.build("WCSLIB")
INFO: Building WCSLIB

WARNING: deprecated syntax "[a=>b, ...]" at /home/jeff/.julia/v0.4/WCSLIB/deps/build.jl:29.
Use "Dict(a=>b, ...)" instead.

julia> Pkg.test("WCSLIB")
INFO: Testing WCSLIB
ERROR: LoadError: test failed: ("WCSAXES =                    2 / Number of coordinate axes                      CRPIX1  =               1818.0 / Pixel coordinate of reference point            CRPIX2  =                969.5 / Pixel coordinate of reference point            CDELT1  =             -0.00825 / [deg] Coordinate increment at reference point  CDELT2  =              0.00825 / [deg] Coordinate increment at reference point  CUNIT1  = 'deg'                / Units of coordinate increment and value        CUNIT2  = 'deg'                / Units of coordinate increment and value        CTYPE1  = 'RA---CEA'           / Right ascension, cylindrical equal area projectCTYPE2  = 'DEC--CEA'           / Declination, cylindrical equal area projection CRVAL1  =                357.5 / [deg] Coordinate value at reference point      CRVAL2  =                  0.0 / [deg] Coordinate value at reference point      PV2_1   =                  1.0 / CEA projection parameter                       LONPOLE =                  0.0 / [deg] Native longitude of celestial pole       LATPOLE =                 90.0 / [deg] Native latitude of celestial pole        RADESYS = 'ICRS'               / Equatorial coordinate system                   " == "WCSAXES =                    2 / Number of coordinate axes                      CRPIX1  =                 1818 / Pixel coordinate of reference point            CRPIX2  =                969.5 / Pixel coordinate of reference point            CDELT1  =             -0.00825 / [deg] Coordinate increment at reference point  CDELT2  =              0.00825 / [deg] Coordinate increment at reference point  CUNIT1  = 'deg'                / Units of coordinate increment and value        CUNIT2  = 'deg'                / Units of coordinate increment and value        CTYPE1  = 'RA---CEA'           / Right ascension, cylindrical equal area projectCTYPE2  = 'DEC--CEA'           / Declination, cylindrical equal area projection CRVAL1  =                357.5 / [deg] Coordinate value at reference point      CRVAL2  =                    0 / [deg] Coordinate value at reference point      PV2_1   =                    1 / CEA projection parameter                       LONPOLE =                    0 / [deg] Native longitude of celestial pole       LATPOLE =                   90 / [deg] Native latitude of celestial pole        RESTFRQ =                    0 / [Hz] Line rest frequency                       RESTWAV =                    0 / [Hz] Line rest wavelength                      RADESYS = 'ICRS'               / Equatorial coordinate system                   ")
 in expression: header[641:end - 240] == header2
 in error at error.jl:19
 in default_handler at test.jl:27
 in do_test at test.jl:50
 in include at ./boot.jl:250
 in include_from_node1 at loading.jl:132
 in process_options at ./client.jl:308
 in _start at ./client.jl:407
while loading /home/jeff/.julia/v0.4/WCSLIB/test/runtests.jl, in expression starting on line 39

====================================[ ERROR: WCSLIB ]=====================================

failed process: Process(`/home/jeff/julia_4/bin/julia --check-bounds=yes --code-coverage=none --color=yes /home/jeff/.julia/v0.4/WCSLIB/test/runtests.jl`, ProcessExited(1)) [1]

==========================================================================================
INFO: No packages to install, update or remove
ERROR: WCSLIB had test errors
 in error at error.jl:19
 in test at pkg/entry.jl:720
 in anonymous at pkg/dir.jl:29
 in cd at file.jl:20
 in cd at pkg/dir.jl:29
 in test at pkg.jl:69
kbarbary commented 9 years ago

Hmmm... I can't reproduce this myself. I wonder if we could be using different versions of the WCSLIB C library. It would be good to have a wrapper for wcslib_version() so we can get the version being used from Julia.

jeff-regier commented 9 years ago

I put the output from dpkg below. Looks like version 4.20-2. Is that older than your version? It's what comes with the "Trusty" release of Ubuntu.

jeff@arina ~ $ dpkg -l | grep wcslib
ii  wcslib-dev                                                  4.20-2                                              amd64        Header files and static library for libwcs
ii  wcslib-tools                                                4.20-2                                              amd64        Command line tools utilizing wcslib
kbarbary commented 9 years ago

I just have the version that WCSLIB.jl downloads and compiles, which is currently 4.25.1.

jeff-regier commented 9 years ago

I tried uninstalling my system's version of the WCSLIB C library ("wcslib-tools" and "wcslib-dev" Ubuntu packagaes), then reinstalling WCSLIB.jl from master. But I get the same error message. A function like wcslib_version() would certainly be nice. In the meantime, is there a way to figure out what version of WCSLIB C library is getting called by WCSLIB.jl on my system?

kbarbary commented 9 years ago

I'm not sure how to do this.

We very well may want to stop using BinDeps here and instead just always build and load WCSLIB from source. Especially since I noticed there is now a new version of WCSLIB that starts with 5.x. I haven't checked, but if it is backwards-incompatible and we switch to it, most system-provided WCSLIBs will be out of date.

Regardless, this test failure doesn't sound catastrophic. The test is sensitive to the exact ordering of keywords in the header. But the order usually doesn't matter to most software and WCSLIB seems to have changed the ordering between versions.

kbarbary commented 9 years ago

I noticed that the wcslib_version() isn't available in WCSLIB v4.25.1. It is in the docs for v5.4 though.