Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arellano_solutions migration to matplotlib 1.4.3 in python 3.4 #190

Closed
finmod opened this issue Sep 17, 2015 · 5 comments
Closed

Arellano_solutions migration to matplotlib 1.4.3 in python 3.4 #190

finmod opened this issue Sep 17, 2015 · 5 comments

Comments

@finmod
Copy link

finmod commented Sep 17, 2015

The following error appears in arellano_solutions in the plotting the last three time series.


TypeError Traceback (most recent call last)
C:\Users\Denis\Anaconda3\lib\site-packages\quantecon\markov\core.py in simulate(self, ts_length, init, num_reps, random_state)
351 try:
--> 352 k = len(init) # init is an array
353 dim = 2

TypeError: object of type 'numpy.int64' has no len()

During handling of the above exception, another exception occurred:

ValueError Traceback (most recent call last)
in ()
1 T = 250
----> 2 y_vec, B_vec, q_vec, default_vec = ae.simulate(T)
3
4 # Pick up default start and end dates
5 start_end_pairs = []

C:\Users\Denis\Anaconda3\lib\site-packages\quantecon\models\arellano_vfi.py in simulate(self, T, y_init, B_init)
164 mc = qe.markov.MarkovChain(self.Py)
165
--> 166 y_sim_indices = mc.simulate(T, init=y_init)
167 B_sim_indices = np.empty(T, dtype=np.int64)
168 B_sim_indices[0] = B_init

C:\Users\Denis\Anaconda3\lib\site-packages\quantecon\markov\core.py in simulate(self, ts_length, init, num_reps, random_state)
367 else:
368 raise ValueError(
--> 369 'init must be int, array_like of ints, or None'
370 )
371

ValueError: init must be int, array_like of ints, or None

@oyamad
Copy link
Member

oyamad commented Sep 17, 2015

@finmod Thank you for the report. This seems to be a bug in MarkovChain.

This line should have been elif isinstance(init, (numbers.Integral, np.integer)): as in here, since "numpy.int64 is not instance of int" (numpy/numpy#2951) (I didn't know this).

To double check, I have to set up a Python 3 environment, and I will then fix this tomorrow.

@oyamad
Copy link
Member

oyamad commented Sep 17, 2015

Maybe elif isinstance(init, numbers.Integral): is enough (numpy/numpy#4547).

@finmod
Copy link
Author

finmod commented Sep 17, 2015

None of the two patches.

TypeError Traceback (most recent call last)

C:\Users\Denis\Anaconda3\lib\site-packages\quantecon\markov\core.py in simulate(self, ts_length, init, num_reps, random_state)

351         try:

--> 352 k = len(init) # init is an array

353             dim = 2

TypeError: object of type 'numpy.int64' has no len()

During handling of the above exception, another exception occurred:

NameError Traceback (most recent call last)

in ()

  1 T = 250

----> 2 y_vec, B_vec, q_vec, default_vec = ae.simulate(T)

  3 

  4 # Pick up default start and end dates

  5 start_end_pairs = []

C:\Users\Denis\Anaconda3\lib\site-packages\quantecon\models\arellano_vfi.py in simulate(self, T, y_init, B_init)

164         mc = qe.markov.MarkovChain(self.Py)

165 

--> 166 y_sim_indices = mc.simulate(T, init=y_init)

167         B_sim_indices = np.empty(T, dtype=np.int64)

168         B_sim_indices[0] = B_init

C:\Users\Denis\Anaconda3\lib\site-packages\quantecon\markov\core.py in simulate(self, ts_length, init, num_reps, random_state)

363             if init is None:

364                 init_states = random_state.randint(self.n, size=k)

--> 365 elif isinstance(init, numbers.Integral):

366                 init_states = np.ones(k, dtype=int) * init

367             else:

NameError: name 'numbers' is not defined

From: Daisuke Oyama [mailto:[email protected]]
Sent: Thursday, September 17, 2015 2:35 PM
To: QuantEcon/QuantEcon.py [email protected]
Cc: finmod [email protected]
Subject: Re: [QuantEcon.py] Arellano_solutions migration to matplotlib 1.4.3 in python 3.4 (#190)

Maybe elif isinstance(init, numbers.Integral): is enough (numpy/numpy#4547 numpy/numpy#4547 ).


Reply to this email directly or view it on GitHub #190 (comment) . https://github.com/notifications/beacon/AMHyIojNBexz_kRQYFUGeei_ZvCQh7_bks5oyqsOgaJpZM4F_BcE.gif

@oyamad
Copy link
Member

oyamad commented Sep 17, 2015

Thanks @finmod, the numbers module has to be imported by import numbers.

@finmod
Copy link
Author

finmod commented Sep 17, 2015

Ok. Spot on by inserting import numbers in core.py and also in the arellano notebook. Thanks

Denis Richard
*


  • Via Panama, 88
  • Rome 00198, Italy
  • Tel: +39 06 83 90 66 29
  • Cel: +39 32 79 76 12 96
  • Email: [email protected]
    *

From: Daisuke Oyama [mailto:[email protected]]
Sent: Thursday, September 17, 2015 4:39 PM
To: QuantEcon/QuantEcon.py [email protected]
Cc: finmod [email protected]
Subject: Re: [QuantEcon.py] Arellano_solutions migration to matplotlib 1.4.3 in python 3.4 (#190)

Thanks @finmod https://github.com/finmod , the numbers module has to be imported by import numbers.


Reply to this email directly or view it on GitHub #190 (comment) . https://github.com/notifications/beacon/AMHyIhY6zmHJooQo21MxlvWZSt8zCrlWks5oysgegaJpZM4F_BcE.gif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants