Lets say I have a Julia module, MyModule
, that defines a function called conv()
for 1D convolution. I would like to be able to call this function via MyModule.conv()
in a file that imports or uses the file. Example:
import MyModule.conv
MyModule.conv()
However, I cannot get this syntax to work; Julia still calls Base.conv()
instead of MyModule.conv()
. I have tried all the different styles of using
and import
but cannot get this syntax to work.
Is this functionality available in Julia? I feel like I have seen this be implemented in other Julia packages but cannot find an example that works.
EDIT
Current setup is as follows; there is no reference to conv() anywhere in ModA outside of the definition.
module ModA
function conv(a, b)
println("ModA.conv")
end
end
Then, in another file,
import ModA
conv(x, y) #still calls Base.conv()
SOLVED
This was entirely my fault. The import wasn't working because of an incorrect LOAD_PATH calling a different version of the file than I thought was being called (finding the first one in the LOAD_PATH, which was not the one that I was editing). Entirely my fault...
using ModA
, thenModA.conv(randn(2), randn(2))
. Is that not the behaviour you are after? – Colin T Bowersimport Base.conv
. – Gnimucimport Base.conv
inModA
then you will be overloading methods onto it, and there will be only oneconv
function at play. As I understand it, the intent here was to keep two separate functions. – Toivo Henningsson