Code Monkey home page Code Monkey logo

Comments (7)

ganong123 avatar ganong123 commented on May 14, 2024

Let me know if there's anything else I can do to help with reproducibility. Here's some platform information.

Version      : 2.7.11
Version tuple: ('2', '7', '11')
Compiler     : GCC 4.2.1 (Apple Inc. build 5577)
Build        : ('default', 'Dec  6 2015 18:57:58')

from hark.

mnwhite avatar mnwhite commented on May 14, 2024

For reproducibility, let's try this:

  1. Download and unpack a fresh copy of the repo; right now, the comments-and-cleanup branch has the most up-to-date code.
  2. Open .../HARK/cstwMPC/cstwMPC.py in Spyder
  3. Click the green arrow "run" button in the toolbar.

That should run a really small estimation ("beta-point infinite horizon") and tell you that beta=0.9893 or so. You can also try doing this for .../HARK/ConsumptionSavingModel/TractableBufferStockModel.py ... That will take ~1 second and solve the same simple model two different ways.

If the method you used to run the modules and get that error is substantially different than the procedure I described, please tell me what you were doing. If there are other ways to run files that should work but don't work, we want to know.

from hark.

 avatar commented on May 14, 2024

ganong123,
The problem could be your python path. I guess that you ran cstwMPC.py in the cstwMPC folder.
In this case, ConsumptionSavingModel could not be called because the compiler did not know where ConsumptionSavingModel is, unless you inserted the path.
Inserting the path is easy. You can see the command line sys.path.insert(0,'../') in cstwMPC.py
Check your Hark-cloned directory. In my case, I write:
sys.path.insert(0,'/Users/yeabinmoon/Documents/HARK-master/ConsumptionSavingModel')

from hark.

mnwhite avatar mnwhite commented on May 14, 2024

John:

Without making that change, do you get the same error? The lines

sys.path.insert(0,'../')
sys.path.insert(0,'../ConsumptionSavingModel')

are meant to work on every machine, no matter where you put HARK, because it's a relative filepath. The intention is that it adds the directory directly above the current one (which should be the root directory of HARK), and the ConsumptionSavingModel directory off of that one.

from hark.

 avatar commented on May 14, 2024

My understanding on python is not quite good to be honest. But,
Using just command
import sys
sys.path.insert(0,'../')
sys.path.insert(0,'../ConsumptionSavingModel')
did not import ConsumptionSavingModel.py. In fact, I had the same problem before. So I added the direct path, and it worked. I am using Jupyter by the way.

from hark.

mnwhite avatar mnwhite commented on May 14, 2024

I have a guess of the problem. Do:

import os
os.getcwd()

That should tell you the current working directory. Before you run a file, the current working directory should be the one that the module is in. You can change the CWD with os.chdir. If you use Spyder and click the green arrow "run" button, it does a version of this by using the runfile command with the wdir keyword.

We strongly recommend using Spyder, an iPython IDE that comes with Anaconda. Just type spyder at a command prompt after installing Anaconda.

from hark.

ganong123 avatar ganong123 commented on May 14, 2024

(1) I was (and continue to be) working in Spyder
(2) cstwMPC.py already had the snippet

import sys 
sys.path.insert(0,'../')
sys.path.insert(0,'../ConsumptionSavingModel')

But this was not sufficient to load the relevant functions.

In any case, switching to comments-and-cleanup branch in my fork resolved the issue. Thanks everyone for your help and I'll continue to report out issues as I find them.

from hark.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.