thaines / helit

My machine learning/computer vision library for all of my recent papers, plus algorithms that I just like.
332 stars 149 forks source link

import error : cannot import name weave #9

Open df19900725 opened 6 years ago

df19900725 commented 6 years ago

I tried to run make_doc.py in dhdp with pycharm, then pycharms console error : import error : cannot import name weave I try to make a new python file which only contains code:

from solve_weave import gibbs_all, gibbs_doc

It still shows the same error. Please help me to find why. thx tim 20180103090403

df19900725 commented 6 years ago

It seems that import 'solve_weave' has circular dependent imports. Firstly, import solve_weave, solve_weave imports State from solve_shared, then solve_shared imports Model from model.py, model imports solvers, then solvers import solve_weave again...

thaines commented 6 years ago

weave is a module that was depreciated from the default scipy install, so you now have to manually install it yourself - you can find it at https://github.com/scipy/weave

P.S. Circular dependencies of that nature are not a problem for Python - its smart enough to handle them correctly.

df19900725 commented 6 years ago

thx a lot. I have solved this problem. Now, I am searching OpenCV1 on Google to run the program since I have found that there are no OpenCV1 in pypi repository. It seems that it is not easy to install open cv1.

thaines commented 6 years ago

Yeah - I'm afraid this code is quite old now. If I remember correctly then all I was using was the OpenCV image output functions, for visualisation - it may be easier to swap them out for the equivalents in scipy.misc instead (they did not exist when I wrote that code!).

df19900725 commented 6 years ago

Anyway, thank you very much for providing the code.

df19900725 commented 6 years ago

Sorry to bore you again. But I really confused by your code about ds_link_cpp. You have written lots of code as follows: ItemRef<Cluster,Conc> * clu = to->clusters.Append(); ItemRef<Topic,Conc> * topicArray = new ItemRef<Topic,Conc>[topicCount];

But I do not understand keyword "ItemRef" because I think it is neither C code nor python code. I also have google it on Web. I did not find answers. Would you please tell me what does it mean or where can I find things about this? Thanks a lot!

thaines commented 6 years ago

Sorry for not getting back to you sooner. ItemRef is defined in linked_list_cpp.py under dp_utils, and it's a C++ class that is using templates; if you haven't seen templates before it can be a bit confusing! In simple terms there is a generic List, where ITEM (the first thing in the angle braces) is the contents of each item in the list, and BODY (the second thing in the angle braces) is something stored once for all items in the list. An ItemRef then points at one item in the list. Effectively, the code uses these definitions of lists to define the data structures for Chinese restaurant processes; the template means the same code can be used for every level of the hierarchy. The ITEM is typically a table at which customers sit, the BODY represents the concentration parameter. Afraid that code is very messy and overly complex - wouldn't write it that way now!

df19900725 commented 6 years ago

Thank you very much. It's so kind of you.