Hi,

I am using julia 0.3.8 + IJulia, and have been using ipython notebook for 
sometime to perform my research activities. For my current project, I 
define and export a number of types and methods wrapped in a module in one 
of the cells, import the module, and refer explicitly to those types and 
methods elsewhere in the notebook. I have found that redefining/reimporting 
the module does not seem to work as expected (code excerpt only):

module mt

export ResultSet, start, next, done

type ResultSet
    models::Array{Any}
    sample_inds::Array{Int64}
    failed::Array{Int64}
    num_fails::Int64
end
start(x::ResultSet) = 1
next(x::ResultSet,i::Int64) = (x.models[i],i+1)
done(x::ResultSet,i::Int64) = (i == length(x.models)+1)

end

import mt;

It works the first time after kernel restart:

mt.start(HD1_HDvC_batch)

1


Later, after editing and rerunning the code:

# model_batch is a ResultSet object
state = mt.start(model_batch)

`start` has no method matching start(::ResultSet)
while loading In[10], in expression starting on line 7


Eventhough:


methods(mt.start)
1 method for generic function *start*:
   
   - start(x::*ResultSet*) at In[9]:33


I have to restart the kernel basically every time I change any of the types or 
their methods. This is currently just an annoyance, but when I start running 
larger analyses in IJulia it will become prohibitive. I am aware of the issues 
with redefining types in the main namespace of an active kernel REPL, the 
workspace() function seems to be practically the same as a kernel restart, and 
defining my types in a module in a cell doesn't seem to fix the resolution 
issues. To my question:

Is there currently a best practice for using IJulia in this way when developing 
with custom types? At least one that does not require a kernel restart every 
time?

I'm still pretty new to julia, so if I am doing anything incorrectly here I'm 
keen to learn. I'd love to use julia+IJulia exclusively for my work as I once 
did for python, but it seems there are some of these issues that are presently 
a barrier to doing that effectively. Does anyone have any suggestions?

Thanks.


Reply via email to