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

Package name conflict #13

Closed
timholy opened this issue Jun 18, 2017 · 21 comments
Closed

Package name conflict #13

timholy opened this issue Jun 18, 2017 · 21 comments

Comments

@timholy
Copy link
Member

timholy commented Jun 18, 2017

I fear this package may have the same problem that the Iterators package has been experiencing:

julia> module Mine
       using FFTW

       struct Foo end

       FFTW.fft(::Foo) = 1

       end
WARNING: both FFTW and Base export "FFTW"; uses of it in module Mine must be qualified
ERROR: UndefVarError: FFTW not defined

julia> versioninfo()
Julia Version 0.7.0-DEV.616
Commit d49469d* (2017-06-16 15:45 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, broadwell)
Environment:
  JULIAHOME = /home/tim/src/julia
  JULIAFUNCDIR = /home/tim/juliafunc
  JULIA_CPU_CORES = 2
@timholy
Copy link
Member Author

timholy commented Jun 18, 2017

Or, following the advice of the docs:

julia> module Mine
       importall FFTW

       struct Foo end

       FFTW.fft(::Foo) = 1

       end
Mine

julia> x = Mine.Foo()
Mine.Foo()

julia> fft(x)
ERROR: fft has been moved to the package FFTW.jl.
Run `Pkg.add("FFTW")` to install FFTW then run `using FFTW` to load it.
Stacktrace:
 [1] #fft#6(::Array{Any,1}, ::Function, ::Mine.Foo, ::Vararg{Mine.Foo,N} where N) at ./deprecated.jl:1448
 [2] fft(::Mine.Foo, ::Vararg{Mine.Foo,N} where N) at ./deprecated.jl:1448

It doesn't help to get rid of the module name in front of the fft specialization.

@ararslan
Copy link
Member

I can't verify at the moment, but the workaround should be

using FFTW
importall FFTW

@timholy
Copy link
Member Author

timholy commented Jun 18, 2017

Nope. Get an error on usage like the one in my 2nd post.

@ararslan
Copy link
Member

Ah, I see, we posted at the same time. :) This package doesn't export anything while FFTW is defined in Base (though I have an unmerged PR here that should make them extend the Base functions when they're deprecated), so you'll have to do using and/or importall outside of the module definition as well.

@timholy
Copy link
Member Author

timholy commented Jun 18, 2017

julia> using FFTW

julia> importall FFTW

julia> module Mine
       using FFTW
       importall FFTW

       struct Foo end

       fft(::Foo) = 1

       end
Mine

julia> x = Mine.Foo()
Mine.Foo()

julia> fft(x)
ERROR: fft has been moved to the package FFTW.jl.
Run `Pkg.add("FFTW")` to install FFTW then run `using FFTW` to load it.
Stacktrace:
 [1] #fft#6(::Array{Any,1}, ::Function, ::Mine.Foo, ::Vararg{Mine.Foo,N} where N) at ./deprecated.jl:1448
 [2] fft(::Mine.Foo, ::Vararg{Mine.Foo,N} where N) at ./deprecated.jl:1448

@ararslan
Copy link
Member

Can you try it after doing Pkg.checkout("FFTW"); Pkg.checkout("FFTW", "aa/testing")?

@timholy
Copy link
Member Author

timholy commented Jun 18, 2017

Same error message.

julia> Pkg.status("FFTW")
 - FFTW                          0.0.1+             aa/testing

@ararslan
Copy link
Member

Maybe

using AbstractFFTs, FFTW
importall AbstractFFTs, FFTW

?

@timholy
Copy link
Member Author

timholy commented Jun 19, 2017

Same error.

@ararslan
Copy link
Member

Well, I have no idea what's going on here. :/

@ararslan
Copy link
Member

This is really concerning. I'm not sure what to do about it. Requesting backup: @stevengj and @tkelman.

@musm
Copy link
Contributor

musm commented Jun 19, 2017

hmm, I too can't get the build to actually follow through:

julia> BinDeps.debug("FFTW")
INFO: Reading build script...
The package declares 2 dependencies.
INFO: Updating WinRPM package list
INFO: Downloading https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Leap_42.2/repodata/repomd.xml
INFO: Downloading https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win64/openSUSE_Leap_42.2/repodata/repomd.xml
 - Library "libfftw3"
    - Providers:
      - BinDeps.AptGet package libfftw3-double3 (can't provide)
      - BinDeps.Pacman package fftw (can't provide)
      - BinDeps.Zypper package libfftw3 (can't provide)
      - BinDeps.Yum package fftw (can't provide)
      - BinDeps.BSDPkg package fftw3 (can't provide)
      - WinRPM.RPM package fftw (can't provide)
      - Simple Build Process
 - Library "libfftw3f"
    - Providers:
      - BinDeps.AptGet package libfftw3-single3 (can't provide)
      - BinDeps.Pacman package fftw (can't provide)
      - BinDeps.Zypper package libfftw3 (can't provide)
      - BinDeps.Yum package fftw (can't provide)
      - BinDeps.BSDPkg package fftw3 (can't provide)
      - WinRPM.RPM package fftw (can't provide)
      - Simple Build Process

Are you sure the WinRPM search is set correctly, e.g.

julia> WinRPM.search("fftw")
WinRPM Package Set:
  1. fftw3-debug (mingw64) - Debug information for package mingw64-fftw3
  2. fftw3-debugsource (mingw64) - Debug sources for package mingw64-fftw3
  3. fftw3-devel (mingw64) - Include Files and Libraries mandatory for Development
  4. libfftw3-3 (mingw64) - Discrete Fourier Transform (DFT) C Subroutine Library

@appleparan
Copy link
Contributor

Seems no problem with fresh install of Julia ver. 0.6.0. Here is test code.

using Base.Test
using FFTW

# simple 1D fft testt
a = rand(8) + im*rand(8)
@test norm(FFTW.ifft(FFTW.fft(a)) - a) < 1e-8

# simple 2D fft test
a = rand(8, 8) + im * rand(8, 8)
@test norm(FFTW.ifft(FFTW.fft(a)) - a) < 1e-8

# 1D FFTW C2R test
a = rand(8) + im * rand(8)
@test norm(FFTW.fft(FFTW.ifft(a)) - a) < 1e-8

# 1D Convolution Test
a = conv(vec([1 2 3]),vec([1 2 3]))
b = FFTW.ifft(FFTW.fft(vec([1 2 3 0 0])) .* FFTW.fft(vec([1 2 3 0 0])))
c = FFTW.ifft(FFTW.fft(vec([1 2 3])) .* FFTW.fft(vec([1 2 3])))
@test norm(a - b) < 1e-8

# 2D FFT Test
a = rand(8, 8) + im * rand(8, 8)
@test norm(FFTW.fft(FFTW.ifft(a)) - a) < 1e-8

@musm
Copy link
Contributor

musm commented Jun 27, 2017

@appleparan The bug is on master, where the bindings have been removed. On 0.6 it will simply use the shipped bindings so it's not a problem

@simonster
Copy link
Member

The reason @timholy's example above doesn't work is that FFTW.jl doesn't export fft.

@ararslan
Copy link
Member

ararslan commented Aug 2, 2017

Should work on 0.6 and 0.7 now. Can you confirm, @timholy?

@ararslan
Copy link
Member

ararslan commented Aug 2, 2017

Okay, seems to work on 0.6 but not 0.7. :/

@stevengj
Copy link
Member

stevengj commented Aug 2, 2017

Shouldn't you just do using AbstractFFTs, FFTW on 0.7 given JuliaLang/julia#22763?

@ararslan
Copy link
Member

ararslan commented Aug 2, 2017

Doesn't make a difference.

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.7.0-DEV.1204 (2017-08-02 20:02 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 27852fdd95* (0 days old master)
|__/                   |  x86_64-apple-darwin16.6.0

julia> module Mine
       using AbstractFFTs, FFTW
       struct Foo end
       FFTW.fft(::Foo) = 1
       end
WARNING: both FFTW and Base export "FFTW"; uses of it in module Mine must be qualified
ERROR: UndefVarError: FFTW not defined

@ararslan
Copy link
Member

ararslan commented Aug 2, 2017

Using importall at least gets you a little further:

julia> module Mine
       importall AbstractFFTs, FFTW
       struct Foo end
       FFTW.fft(::Foo) = 1
       end
Mine

julia> using Mine

julia> fft(Mine.Foo())
ERROR: Base.DFT.fft has been moved to the package FFTW.jl.
Run `Pkg.add("FFTW")` to install it, restart Julia,
and then run `using FFTW` to load it.
Stacktrace:
 [1] error(::Function, ::String, ::String, ::String, ::String, ::String, ::String, ::String, ::String, ::String) at ./error.jl:39
 [2] #fft#6(::Array{Any,1}, ::Function, ::Mine.Foo, ::Vararg{Mine.Foo,N} where N) at ./deprecated.jl:128
 [3] fft(::Mine.Foo, ::Vararg{Mine.Foo,N} where N) at ./deprecated.jl:128

@ararslan
Copy link
Member

ararslan commented Aug 2, 2017

Wow, I'm an idiot. I forgot using FFTW outside of the module declaration. The latter works with importall.

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

6 participants