Code Monkey home page Code Monkey logo

Comments (8)

dclow avatar dclow commented on May 14, 2024

That's really odd. It seems like it's trying to execute line 2242 of "ConsIndShockModel.py" without also executing line 2243, which is what the + \ at the end is telling it to do

Are you using Spyder? How are you executing Python code? Have you changed any of the files at all?

from hark.

asmileguo avatar asmileguo commented on May 14, 2024

I found that changing line 2242 into
raise Exception("grid_type not recognized in init." +
"Please ensure grid_type is 'linear' or 'exp_mult'")

solves the problem (at least for the first line error I mentioned).
Was it due to different versions of Python? I run it in Python 3 Jupyter notebook.

from hark.

dclow avatar dclow commented on May 14, 2024

Hmmmmm yeah that sounds very possible. HARK is written for and tested in Python 2.7

I'd recommend downloading and installing Python 2.7 if you want to use HARK. If that doesn't fix the problem, please let me know

from hark.

asmileguo avatar asmileguo commented on May 14, 2024

Thanks David. I'll just check how far it can go with Python 3.

from hark.

compumetrika avatar compumetrika commented on May 14, 2024

I can confirm that the error described above occurs under python 3, but not python 2.

Here is my effort to run the demo with Python 3:

$ cd ~/workspace/HARK/ConsumptionSaving/
$ python3 Demo.py 
Traceback (most recent call last):
  File "Demo.py", line 27, in <module>
    from ConsIndShockModel import IndShockConsumerType
  File "/home/npalmer/workspace/NEW_HARK/ConsumptionSaving/ConsIndShockModel.py", line 2242
    raise Exception, "grid_type not recognized in __init__." + \
                   ^
SyntaxError: invalid syntax

...the same error.

Under Python2.7:

$ python Demo.py 
divide by zero encountered in log
Consumption functions:
MPC out of Credit v MPC out of Income
$

As @dclow noted, HARK has been written for Python 2.7; unfortunately this appears to be one of the places that Python 2/3 differences crop up. Ideally our code would run under both, but as noted above it has only been tested in Python 2.7. There may be more to be said on this.

Thanks for catching this. (Not closing the issue just yet.)

from hark.

asmileguo avatar asmileguo commented on May 14, 2024

@compumetrika @dclow Thanks for the help. I also confirmed that I could run it on Python 2.7 on my machine without any issues.

from hark.

mnwhite avatar mnwhite commented on May 14, 2024

Should we close this issue now, and replace it with one entitled "make HARK compatible with Python 3"?

from hark.

mnwhite avatar mnwhite commented on May 14, 2024

Closing because no one has objected to my suggestion for three months.

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.