Skip to content

Commit 4cc5bf9

Browse files
committed
Commit before mini-release 0.95.9
1 parent 6bac9fb commit 4cc5bf9

File tree

9 files changed

+123
-28
lines changed

9 files changed

+123
-28
lines changed

pymaclab/dsge/parsers/_dsgeparser.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,9 +1370,8 @@ def differ_out(self):
13701370
patup = ('{-10,10}|None','endo|con|exo|other','{-10,10}')
13711371
# Collect some necessary info for steady state substitutions
13721372
var_bar = []
1373-
varnames = deepcopy(self.vardic)
13741373
for elem in ['con','endo','exo','other']:
1375-
tmp_li = [x[0].split('(')[0]+'_bar' for x in varnames[elem]['var']]
1374+
tmp_li = [x[0].split('(')[0]+'_bar' for x in self.vardic[elem]['var']]
13761375
for elem2 in tmp_li:
13771376
var_bar.append(elem2)
13781377
for kk1,elem in enumerate(list_tmp2):

pymaclab/dsge/updaters/one_off.py

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,34 @@ def __str__(self):
165165
return self.wrapdic.__str__()
166166

167167
class listwrapk:
168-
def __init__(self,other,wrapobj,initlev):
168+
def __init__(self,other,wrapobj,wrapobj_str,wrapdic,initlev):
169169
self.other = other
170170
self.wrapobj = wrapobj
171+
self.wrapobj_str = wrapobj_str
172+
self.wrapdic = wrapdic
171173
self.initlev = initlev
172174
self.wrapli = deepcopy(wrapobj)
175+
176+
def reinit(self,other):
177+
# Need to copy manually as inner wrapped objects do not support deepcopy
178+
if self.wrapobj_str == 'self.vardic':
179+
var_keys = []
180+
for keyo in other.vardic.keys():
181+
var_keys.append(keyo)
182+
del other.vardic
183+
other.vardic = {}
184+
for keyo in var_keys:
185+
other.vardic[keyo]={}
186+
other.vardic[keyo]['var']=[]
187+
other.vardic[keyo]['mod']=[]
188+
for keyo1 in self.wrapdic.keys():
189+
for keyo2 in self.wrapdic[keyo1].keys():
190+
other.vardic[keyo1][keyo2] = []
191+
for i1,elem1 in enumerate(self.wrapdic[keyo1][keyo2]):
192+
other.vardic[keyo1][keyo2].append([])
193+
for i2,elem2 in enumerate(elem1):
194+
other.vardic[keyo1][keyo2][i1].append(elem2)
195+
173196

174197
def __getattr__(self,attrname):
175198
return getattr(self.wrapli,attrname)
@@ -187,8 +210,8 @@ def __setslice__(self,ind1,ind2,into):
187210
if self.wrapli[ind1:ind2] != into:
188211
self.wrapli[ind1:ind2] = into
189212
wrapobj[ind1:ind2] = into
190-
other.vardic.update(other.updaters.vardic)
191-
other.updaters.vardic.wrapobj.update(other.updaters.vardic)
213+
other.updaters.vardic.wrapobj.update(other.updaters.vardic)
214+
self.reinit(other)
192215

193216
other.inits.init1a()
194217

@@ -225,8 +248,8 @@ def __setitem__(self,ind,into):
225248
if self.wrapli[ind] != into:
226249
self.wrapli[ind] = into
227250
wrapobj[ind] = into
228-
other.vardic.update(other.updaters.vardic)
229251
other.updaters.vardic.wrapobj.update(other.updaters.vardic)
252+
self.reinit(other)
230253

231254
other.inits.init1a()
232255

@@ -373,7 +396,7 @@ def __init__(self,other,wrapobj_str,initlev):
373396
for keyo2 in self.wrapdic[keyo].keys():
374397
self.wrapdic[keyo][keyo2] = dicwrapk(other,self.wrapdic[keyo][keyo2],initlev)
375398
for i1,elem in enumerate(self.wrapdic[keyo][keyo2]):
376-
self.wrapdic[keyo][keyo2][i1] = listwrapk(other,self.wrapdic[keyo][keyo2][i1],initlev)
399+
self.wrapdic[keyo][keyo2][i1] = listwrapk(other,self.wrapdic[keyo][keyo2][i1],self.wrapobj_str,self.wrapdic,initlev)
377400

378401
def __getattr__(self,attrname):
379402
return getattr(self.wrapdic,attrname)
@@ -384,12 +407,29 @@ def __setitem__(self,key,value):
384407
wrapobj = self.wrapobj
385408
wrapobj[key] = value
386409
# Test if the dictionary has changed relative to self.wrapdic
387-
if self.wrapdic != wrapobj:
410+
if self.wrapdic[key] != wrapobj[key]:
388411
self.wrapdic[key] = value
389412
##### THE INITS #####################
390413
#other.inits.init1()
414+
# Need to copy manually as inner wrapped objects do not support deepcopy
391415
if wrapobj_str == 'self.vardic':
392-
other.vardic.upate(wrapobj)
416+
var_keys = []
417+
for keyo in other.vardic.keys():
418+
var_keys.append(keyo)
419+
del other.vardic
420+
other.vardic = {}
421+
for keyo in var_keys:
422+
other.vardic[keyo]={}
423+
other.vardic[keyo]['var']=[]
424+
other.vardic[keyo]['mod']=[]
425+
for keyo1 in self.wrapdic.keys():
426+
for keyo2 in self.wrapdic[keyo1].keys():
427+
other.vardic[keyo1][keyo2] = []
428+
for i1,elem1 in enumerate(self.wrapdic[keyo1][keyo2]):
429+
other.vardic[keyo1][keyo2].append([])
430+
for i2,elem2 in enumerate(elem1):
431+
other.vardic[keyo1][keyo2][i1].append(elem2)
432+
393433

394434
other.inits.init1a()
395435
if wrapobj_str == 'self.nlsubsdic':
@@ -431,8 +471,24 @@ def __update__(self,dico):
431471
self.wrapdic.update(dico)
432472
##### THE INITS #####################
433473
#other.inits.init1()
474+
# Need to copy manually as inner wrapped objects do not support deepcopy
434475
if wrapobj_str == 'self.vardic':
435-
other.vardic.upate(self.wrapdic)
476+
var_keys = []
477+
for keyo in other.vardic.keys():
478+
var_keys.append(keyo)
479+
del other.vardic
480+
other.vardic = {}
481+
for keyo in var_keys:
482+
other.vardic[keyo]={}
483+
other.vardic[keyo]['var']=[]
484+
other.vardic[keyo]['mod']=[]
485+
for keyo1 in self.wrapdic.keys():
486+
for keyo2 in self.wrapdic[keyo1].keys():
487+
other.vardic[keyo1][keyo2] = []
488+
for i1,elem1 in enumerate(self.wrapdic[keyo1][keyo2]):
489+
other.vardic[keyo1][keyo2].append([])
490+
for i2,elem2 in enumerate(elem1):
491+
other.vardic[keyo1][keyo2][i1].append(elem2)
436492

437493
other.inits.init1a()
438494

pymaclab/dsge/updaters/queued.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,21 @@ def __init__(self,other=None):
346346
self.other = other
347347
self.queue = other.updaters_queued.queue
348348
self.initlev = other._initlev
349-
# The vardic
350-
self.vardic = deepcopy(other.updaters_queued.vardic.wrapobj)
349+
350+
# The vardic, do manually in order to avoid deepcopy problem with custom instances
351+
self.vardic = {}
352+
var_keys = []
353+
for keyo in other.updaters_queued.vardic.wrapobj.keys():
354+
var_keys.append(keyo)
355+
for keyo in var_keys:
356+
self.vardic[keyo] = {}
357+
self.vardic[keyo]['var']= []
358+
self.vardic[keyo]['mod']= []
359+
for keyo1 in other.updaters_queued.vardic.wrapobj.keys():
360+
for keyo2 in other.updaters_queued.vardic.wrapobj[keyo1].keys():
361+
self.vardic[keyo1][keyo2]=[]
362+
for i1,elem1 in enumerate(other.updaters_queued.vardic.wrapobj[keyo1][keyo2]):
363+
self.vardic[keyo1][keyo2].append([x for x in elem1])
351364
# The nlsubsdic
352365
if 'nlsubsdic' in dir(other):
353366
self.nlsubsdic = deepcopy(other.updaters_queued.nlsubsdic.wrapobj)
@@ -367,8 +380,24 @@ def __init__(self,other=None):
367380

368381
def reinit(self):
369382
other = self.other
370-
# The vardic
371-
self.vardic = deepcopy(other.updaters_queued.vardic.wrapobj)
383+
# Save the original var categories before deleting original vardic
384+
var_keys = []
385+
for keyo in self.vardic.keys():
386+
var_keys.append(keyo)
387+
# Delete and re-build
388+
del self.vardic
389+
self.vardic = {}
390+
for keyo in var_keys:
391+
self.vardic[keyo]={}
392+
self.vardic[keyo]['var']=[]
393+
self.vardic[keyo]['mod']=[]
394+
# The vardic, can't use deepcopy because the nested instances don't implement it
395+
for keyo1 in other.updaters_queued.vardic.wrapobj.keys():
396+
for keyo2 in other.updaters_queued.vardic.wrapobj[keyo1].keys():
397+
for i1,elem1 in enumerate(other.updaters_queued.vardic.wrapobj[keyo1][keyo2]):
398+
self.vardic[keyo1][keyo2].append([elem2 for elem2 in elem1])
399+
400+
#self.vardic = deepcopy(other.updaters_queued.vardic.wrapobj)
372401
# The nlsubsdic
373402
if 'nlsubsdic' in dir(other):
374403
self.nlsubsdic = deepcopy(other.updaters_queued.nlsubsdic.wrapobj)

pymaclab/tests/pymaclab_tests/modfiles_tests/templates_tests/test_wheezy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ def test_others():
3535
# Remove models which need external file or otherwise don't work
3636
modelli.remove('rbc1_ext')
3737
modelli.remove('rbc1_extss')
38-
modelli.remove('prog')
3938
modelli.remove('jermann98_ext')
39+
modelli.remove('jermann98')
40+
modelli.remove('grohurib03')
41+
modelli.remove('merz')
4042

4143
for modelo in modelli:
4244
print "Now testing for model: ",modelo

pymaclab_sphinx/CHANGES

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@
44
Release History
55
===============
66

7+
**0.95.9** (2012-12-16)
8+
==========================
9+
10+
* Fixed small bug in updater function which should have been fixed for 0.95.8.
11+
12+
13+
**0.95.8** (2012-12-15)
14+
==========================
15+
16+
* Introduced indicator function feature in variable substitution section in order to manage discontinuities in FOCs.
17+
18+
* The magnitude and sign of shock can now be passed to IRF-generating method.
19+
20+
* Certain methods in pymaclab have been refactored and cleaned up considerably, making code more robust.
21+
22+
* Much work done on getting closer to having a pymaclab-to-dynare translator (but not quite there yet).
23+
24+
725
**0.95.1** (2012-10-8)
826
==========================
927

pymaclab_sphinx/docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@
8484
# version: The short X.Y version.
8585
# release: The full version, including alpha/beta/rc tags.
8686
from cloud_sptheme import __version__ as release
87-
release = "0.95.1"
88-
version = "0.95.1"
87+
release = "0.95.9"
88+
version = "0.95.9"
8989

9090
# The language for content autogenerated by Sphinx. Refer to documentation
9191
# for a list of supported languages.

pymaclab_sphinx/docs/index.rst

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,7 @@ First things first
3636
* Latest source tar ball at `http://pypi.python.org/pypi/pymaclab/ <http://pypi.python.org/pypi/pymaclab/>`_
3737
* Latest bleeding-edge source via git at `http://github.com/escheffel/pymaclab <http://github.com/escheffel/pymaclab>`_
3838
* Source code issues tracker at `http://github.com/escheffel/pymaclab/issues/ <http://github.com/escheffel/pymaclab/issues/>`_
39-
40-
.. note::
4139

42-
If you want to give PyMacLab a try without installing it onto your own computer you can access an IPython web server frontend in which
43-
you can create notebooks (as in Mathematica and Maple) from which calls to Python, Numpy, Scipy and PyMacLab can be made. Plots are
44-
directly rendered to screen. Access this experimental web portal at:
45-
46-
`http://www.notebook.pymaclab.com <http://notebook.pymaclab.com>`_
47-
48-
There you will also find provided example scripts which can be run inside your webbrowser.
4940

5041
Features at a Glance
5142
--------------------
@@ -224,7 +215,7 @@ Option 2
224215

225216
Otherwise get the latest source code compressed as a tarball here:
226217

227-
`pymaclab.tar.gz <http://pypi.python.org/packages/source/p/pymaclab/pymaclab-0.95.1.tar.gz>`_
218+
`pymaclab.tar.gz <http://pypi.python.org/packages/source/p/pymaclab/pymaclab-0.95.8.tar.gz>`_
228219

229220
And install it in the usual way by running in a Linux shell the command::
230221

version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from datetime import datetime
22

3-
version = '0.95.1'
3+
version = '0.95.9'

0 commit comments

Comments
 (0)