ModelFlowIb 2.51__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. modelflowib-2.51/ModelFlowIb.egg-info/PKG-INFO +33 -0
  2. modelflowib-2.51/ModelFlowIb.egg-info/SOURCES.txt +49 -0
  3. modelflowib-2.51/ModelFlowIb.egg-info/dependency_links.txt +1 -0
  4. modelflowib-2.51/ModelFlowIb.egg-info/requires.txt +29 -0
  5. modelflowib-2.51/ModelFlowIb.egg-info/top_level.txt +44 -0
  6. modelflowib-2.51/PKG-INFO +33 -0
  7. modelflowib-2.51/modelBLfunk.py +97 -0
  8. modelflowib-2.51/model_Excel.py +332 -0
  9. modelflowib-2.51/model_cvx.py +132 -0
  10. modelflowib-2.51/model_doable.py +40 -0
  11. modelflowib-2.51/model_dynare.py +173 -0
  12. modelflowib-2.51/model_financial_stability.py +88 -0
  13. modelflowib-2.51/model_ifrs9.py +88 -0
  14. modelflowib-2.51/model_latex.py +526 -0
  15. modelflowib-2.51/model_latex_class.py +698 -0
  16. modelflowib-2.51/model_run_numba.py +15 -0
  17. modelflowib-2.51/modelclass.py +8758 -0
  18. modelflowib-2.51/modelclass2.py +463 -0
  19. modelflowib-2.51/modeldash.py +265 -0
  20. modelflowib-2.51/modeldashboot.py +202 -0
  21. modelflowib-2.51/modeldashsidebar.py +456 -0
  22. modelflowib-2.51/modeldekom.py +644 -0
  23. modelflowib-2.51/modeldiff.py +561 -0
  24. modelflowib-2.51/modeldisplay.py +550 -0
  25. modelflowib-2.51/modelfeedback.py +243 -0
  26. modelflowib-2.51/modelgrab.py +318 -0
  27. modelflowib-2.51/modelgrabwf2.py +1047 -0
  28. modelflowib-2.51/modelhelp.py +254 -0
  29. modelflowib-2.51/modelinvert.py +250 -0
  30. modelflowib-2.51/modeljupyter.py +824 -0
  31. modelflowib-2.51/modeljupytermagic.py +374 -0
  32. modelflowib-2.51/modelmacrograb.py +98 -0
  33. modelflowib-2.51/modelmanipulation.py +1373 -0
  34. modelflowib-2.51/modelmf.py +270 -0
  35. modelflowib-2.51/modelnet.py +114 -0
  36. modelflowib-2.51/modelnewton.py +1803 -0
  37. modelflowib-2.51/modelnormalize.py +388 -0
  38. modelflowib-2.51/modelpattern.py +293 -0
  39. modelflowib-2.51/modelpatternrev.py +72 -0
  40. modelflowib-2.51/modelreport.py +2167 -0
  41. modelflowib-2.51/modelsandbox.py +76 -0
  42. modelflowib-2.51/modelsandbox_Mixin.py +1565 -0
  43. modelflowib-2.51/modeltodo.py +31 -0
  44. modelflowib-2.51/modeluserfunk.py +97 -0
  45. modelflowib-2.51/modeluserfunk_old.py +90 -0
  46. modelflowib-2.51/modelvis.py +1033 -0
  47. modelflowib-2.51/modelwidget.py +706 -0
  48. modelflowib-2.51/modelwidget_input.py +1210 -0
  49. modelflowib-2.51/modelwidget_shinypy.py +935 -0
  50. modelflowib-2.51/pyproject.toml +44 -0
  51. modelflowib-2.51/setup.cfg +4 -0
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 2.2
2
+ Name: ModelFlowIb
3
+ Version: 2.51
4
+ Summary: A tool to solve and manage dynamic economic models
5
+ Author-email: Ib Hansen <your@email.com>
6
+ License: MIT
7
+ Requires-Dist: pandas
8
+ Requires-Dist: matplotlib
9
+ Requires-Dist: seaborn
10
+ Requires-Dist: sympy
11
+ Requires-Dist: numpy
12
+ Requires-Dist: networkx
13
+ Requires-Dist: tqdm
14
+ Requires-Dist: scipy
15
+ Requires-Dist: numexpr
16
+ Requires-Dist: bottleneck
17
+ Requires-Dist: XlsxWriter
18
+ Requires-Dist: pyarrow
19
+ Requires-Dist: tabulate
20
+ Requires-Dist: openpyxl
21
+ Requires-Dist: xarray
22
+ Requires-Dist: cvxopt
23
+ Requires-Dist: numba
24
+ Requires-Dist: dash
25
+ Requires-Dist: dash-bootstrap-components
26
+ Requires-Dist: dash-interactive-graphviz
27
+ Provides-Extra: jupyter
28
+ Requires-Dist: jupyter; extra == "jupyter"
29
+ Requires-Dist: ipywidgets; extra == "jupyter"
30
+ Requires-Dist: ipysheet; extra == "jupyter"
31
+ Provides-Extra: shiny
32
+ Requires-Dist: shiny; extra == "shiny"
33
+ Requires-Dist: shinywidgets; extra == "shiny"
@@ -0,0 +1,49 @@
1
+ modelBLfunk.py
2
+ model_Excel.py
3
+ model_cvx.py
4
+ model_doable.py
5
+ model_dynare.py
6
+ model_financial_stability.py
7
+ model_ifrs9.py
8
+ model_latex.py
9
+ model_latex_class.py
10
+ model_run_numba.py
11
+ modelclass.py
12
+ modelclass2.py
13
+ modeldash.py
14
+ modeldashboot.py
15
+ modeldashsidebar.py
16
+ modeldekom.py
17
+ modeldiff.py
18
+ modeldisplay.py
19
+ modelfeedback.py
20
+ modelgrab.py
21
+ modelgrabwf2.py
22
+ modelhelp.py
23
+ modelinvert.py
24
+ modeljupyter.py
25
+ modeljupytermagic.py
26
+ modelmacrograb.py
27
+ modelmanipulation.py
28
+ modelmf.py
29
+ modelnet.py
30
+ modelnewton.py
31
+ modelnormalize.py
32
+ modelpattern.py
33
+ modelpatternrev.py
34
+ modelreport.py
35
+ modelsandbox.py
36
+ modelsandbox_Mixin.py
37
+ modeltodo.py
38
+ modeluserfunk.py
39
+ modeluserfunk_old.py
40
+ modelvis.py
41
+ modelwidget.py
42
+ modelwidget_input.py
43
+ modelwidget_shinypy.py
44
+ pyproject.toml
45
+ ModelFlowIb.egg-info/PKG-INFO
46
+ ModelFlowIb.egg-info/SOURCES.txt
47
+ ModelFlowIb.egg-info/dependency_links.txt
48
+ ModelFlowIb.egg-info/requires.txt
49
+ ModelFlowIb.egg-info/top_level.txt
@@ -0,0 +1,29 @@
1
+ pandas
2
+ matplotlib
3
+ seaborn
4
+ sympy
5
+ numpy
6
+ networkx
7
+ tqdm
8
+ scipy
9
+ numexpr
10
+ bottleneck
11
+ XlsxWriter
12
+ pyarrow
13
+ tabulate
14
+ openpyxl
15
+ xarray
16
+ cvxopt
17
+ numba
18
+ dash
19
+ dash-bootstrap-components
20
+ dash-interactive-graphviz
21
+
22
+ [jupyter]
23
+ jupyter
24
+ ipywidgets
25
+ ipysheet
26
+
27
+ [shiny]
28
+ shiny
29
+ shinywidgets
@@ -0,0 +1,44 @@
1
+ dist
2
+ modelBLfunk
3
+ model_Excel
4
+ model_cvx
5
+ model_doable
6
+ model_dynare
7
+ model_financial_stability
8
+ model_ifrs9
9
+ model_latex
10
+ model_latex_class
11
+ model_run_numba
12
+ modelclass
13
+ modelclass2
14
+ modeldash
15
+ modeldashboot
16
+ modeldashsidebar
17
+ modeldekom
18
+ modeldiff
19
+ modeldisplay
20
+ modelfeedback
21
+ modelgrab
22
+ modelgrabwf2
23
+ modelhelp
24
+ modelinvert
25
+ modeljupyter
26
+ modeljupytermagic
27
+ modelmacrograb
28
+ modelmanipulation
29
+ modelmf
30
+ modelnet
31
+ modelnewton
32
+ modelnormalize
33
+ modelpattern
34
+ modelpatternrev
35
+ modelreport
36
+ modelsandbox
37
+ modelsandbox_Mixin
38
+ modeltodo
39
+ modeluserfunk
40
+ modeluserfunk_old
41
+ modelvis
42
+ modelwidget
43
+ modelwidget_input
44
+ modelwidget_shinypy
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 2.2
2
+ Name: ModelFlowIb
3
+ Version: 2.51
4
+ Summary: A tool to solve and manage dynamic economic models
5
+ Author-email: Ib Hansen <your@email.com>
6
+ License: MIT
7
+ Requires-Dist: pandas
8
+ Requires-Dist: matplotlib
9
+ Requires-Dist: seaborn
10
+ Requires-Dist: sympy
11
+ Requires-Dist: numpy
12
+ Requires-Dist: networkx
13
+ Requires-Dist: tqdm
14
+ Requires-Dist: scipy
15
+ Requires-Dist: numexpr
16
+ Requires-Dist: bottleneck
17
+ Requires-Dist: XlsxWriter
18
+ Requires-Dist: pyarrow
19
+ Requires-Dist: tabulate
20
+ Requires-Dist: openpyxl
21
+ Requires-Dist: xarray
22
+ Requires-Dist: cvxopt
23
+ Requires-Dist: numba
24
+ Requires-Dist: dash
25
+ Requires-Dist: dash-bootstrap-components
26
+ Requires-Dist: dash-interactive-graphviz
27
+ Provides-Extra: jupyter
28
+ Requires-Dist: jupyter; extra == "jupyter"
29
+ Requires-Dist: ipywidgets; extra == "jupyter"
30
+ Requires-Dist: ipysheet; extra == "jupyter"
31
+ Provides-Extra: shiny
32
+ Requires-Dist: shiny; extra == "shiny"
33
+ Requires-Dist: shinywidgets; extra == "shiny"
@@ -0,0 +1,97 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Fri Mar 2 17:01:49 2018
4
+
5
+ @author: hanseni
6
+
7
+ Functions placed here are included in the Pyfs business language
8
+
9
+ """
10
+ from math import exp, log, sqrt, tanh
11
+ from numpy import transpose , array
12
+ from scipy.stats import norm,lognorm
13
+ from scipy.stats import gamma
14
+ import inspect
15
+
16
+ try:
17
+ # raise ImportError("Simulating ImportError for numba.")
18
+
19
+ from numba import jit
20
+ except ImportError:
21
+ print("Numba is not available. No worry")
22
+
23
+ def jit(*args, **kwargs):
24
+ def wrapper(func):
25
+ # print('jit called')
26
+ return func
27
+ return wrapper
28
+
29
+ @jit("f8(f8)",nopython=True)
30
+ def logit_inverse(number):
31
+ ''' A function which returns the logit of a number
32
+
33
+ takes care of extreme values
34
+ '''
35
+ if number > 100:
36
+ return 1.0
37
+ elif number < -100:
38
+ return 0.0
39
+ else:
40
+ return 1/(1+exp(-number))
41
+
42
+ classfunk = []
43
+ try:
44
+ from cvxopt import matrix
45
+ from model_cvx import mv_opt, mv_opt_prop
46
+ classfunk = ['TRANS'] # names a classfunk which can be called
47
+ except:
48
+ print('ModelFlow info: CVXopt not installed. Only matters if you are incorporating optimization')
49
+ pass
50
+
51
+ from numpy import array
52
+
53
+ from model_financial_stability import lifetime_credit_loss
54
+
55
+ def sum_excel(*arg):
56
+ ''' a functions which sums the arguments used in models franslated from excel
57
+ '''
58
+ return sum(arg)
59
+
60
+ def logit(number):
61
+ ''' A function which returns the logit of a number
62
+ '''
63
+ return(-log(1.0/number-1.0))
64
+
65
+ # @jit("f8(f8)")
66
+ # def logit_inverse(number):
67
+ # ''' A function which returns the logit of a number
68
+
69
+ # takes care of extreme values
70
+ # '''
71
+ # if number > 100:
72
+ # return 1.0
73
+ # elif number < -100:
74
+ # return 0.0
75
+ # else:
76
+ # return 1/(1+exp(-number))
77
+
78
+ def normcdf(input,mu=0.0,sigma=1.0):
79
+ return norm.cdf(input,mu,sigma)
80
+
81
+
82
+ def qgamma(q,a,loc):
83
+ res = gamma.ppf(q,a,loc,scale=1)
84
+ return res
85
+
86
+
87
+
88
+ def clognorm(input,mu=0.0,sigma=1.0):
89
+ res = lognorm.cdf(input,mu,sigma)
90
+ return res
91
+
92
+ if __name__ == '__main__' and 1:
93
+ xx = logit_inverse(-3*10
94
+ )
95
+ print(xx)
96
+
97
+
@@ -0,0 +1,332 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Fri Feb 12 07:04:02 2016
4
+
5
+ @author: ibh
6
+
7
+ Takes all formula's from a excel work book and translates each to the equivalent expression.
8
+ Openpyxl is the fastest library but it can not deal all values. Therefor xlwings is also used.
9
+ But only to read repeated formula's which inly will show as '='
10
+
11
+
12
+
13
+ Also defines function used when using xlwings to automate excel.
14
+
15
+ These are used in :any:`modeldump_excel` and :any:`modelload_excel`
16
+
17
+ Some of the docstring are not very informative, to be improved.
18
+
19
+
20
+
21
+ """
22
+ import pandas as pd
23
+ import networkx as nx
24
+ import openpyxl
25
+ from openpyxl import load_workbook
26
+ from openpyxl.formula import Tokenizer
27
+ from openpyxl.utils import get_column_letter
28
+ from openpyxl.utils import cols_from_range,rows_from_range
29
+ # try:
30
+ # import xlwings as xw
31
+ # except:
32
+ # ...
33
+ # import networkx as nx
34
+
35
+ import matplotlib.pylab as plt
36
+ import seaborn as sns
37
+ from pathlib import Path
38
+
39
+ import modelclass as mc
40
+
41
+ DEBUG = 0
42
+
43
+ def findequations(name):
44
+ '''Takes all formula's from a excel work book and translates each to the equivalent expression.
45
+
46
+ Multicell ranges are expanded to a comma separated list. \n
47
+ The ordinary operators and the SUM function can be handled. If you need more functions. You have to impelent them in the modelclass.
48
+
49
+ In the model each cell reference is prefixed by <sheet name>_
50
+
51
+ Openpyxl is the fastest library and it has a tokenizer
52
+ but it can not read all values.
53
+
54
+ Therefor xlwings is used to read repeated formula's which Openpyxl will show as '='
55
+
56
+ input:
57
+ :name: Location of a excel sheeet
58
+
59
+
60
+ Returns:
61
+ :modeldic: A dictionary with formulars keyed by cell reference
62
+
63
+ '''
64
+ outdic={}
65
+ wb = load_workbook(name, read_only=True,data_only=False) # to read the spresdsheet first save as xml then write it again
66
+ try:
67
+ wb2 = xw.Book(name) # the same worksheet in xlwings
68
+ except:
69
+ ...
70
+ # breakpoint()
71
+
72
+ allsheets = wb.sheetnames
73
+ for wsname in allsheets:
74
+ ws=wb[wsname]
75
+ try:
76
+ ws2=wb2.sheets(wsname) # the same sheet but in xlwings
77
+ except:
78
+ ...
79
+
80
+ formulacell = [c for row in ws.rows for c in row if c.value != None and c.data_type == 'f']
81
+ for cell in formulacell:
82
+ cellref=get_column_letter(cell.column)+str(cell.row)
83
+ if DEBUG : print('This cell:',cellref,cell.data_type,cell.value)
84
+ if cell.value == '=' :
85
+ print(f'Repeat cell = so xlwings has to be imported {cell=}')
86
+ frml = cell.value if cell.value != '=' else ws2.range(cellref).formula # To avoid emty repeating formula'rs
87
+ else:
88
+ frml = cell.value
89
+ tok=Tokenizer(frml)
90
+ if DEBUG and False : print("\n".join("%19s%15s%9s" % (t.value, t.type, t.subtype) for t in tok.items))
91
+ # left hand term is <worksheet>!<column><row>=
92
+ lhs=wstrans(wsname) + get_column_letter(cell.column)+str(cell.row)
93
+ out=[lhs+'=']
94
+ for t in tok.items:
95
+ if t.subtype == "RANGE":
96
+ #Find or create the sheetname
97
+ sheet0 = t.value.split('!')[0] if '!' in t.value else wsname
98
+ sheet = wstrans(sheet0)
99
+ # print(t.value,'---->')
100
+ # Get all the cells in the range columwize
101
+ # the nested list comprehension makes the list works for square ranges.
102
+ # the split construct drops the sheet name from the range name if any
103
+ thisrange=[sheet+i for subtupler in cols_from_range((t.value.split('!')[-1])) for i in subtupler]
104
+
105
+ # put a ',' between each element i the list
106
+ thistext=','.join(thisrange)
107
+ #print(thisrange)
108
+ out=out + [thistext]
109
+ else:
110
+ out.append(t.value)
111
+ #create the equation and get rid of the !
112
+ equation=''.join(out).replace('!','_')
113
+ outdic[lhs]=equation
114
+ #print(equation)
115
+ try:
116
+ wb2.close()
117
+ except:
118
+ ...
119
+ return outdic
120
+
121
+ def showcells(name):
122
+ '''Finds values in a excel workbook with a value different from 0
123
+ '''
124
+ wb = load_workbook(name, read_only=True,data_only=False) # to read the spresdsheet first save as xml then write it again
125
+ allsheets = wb.sheetnames
126
+ for wsname in allsheets:
127
+ ws=wb[wsname]
128
+ for row in ws.rows:
129
+ for c in row:
130
+ if c.value != None:
131
+ print(wsname,get_column_letter(c.column ),c.row,c.data_type,c.value)
132
+
133
+
134
+ def findvalues(name):
135
+ '''Finds numerical values in a excel workbook with a value different from 0
136
+ '''
137
+ wb = load_workbook(name, read_only=True,data_only=True) # to read the spresdsheet first save as xml then write it again
138
+ allsheets = wb.sheetnames
139
+ values=[]
140
+ for wsname in allsheets:
141
+ ws=wb[wsname]
142
+ twsname = wstrans(wsname)
143
+ values+=[(twsname+get_column_letter(c.column )+str(c.row),c.value)
144
+ for row in ws.rows for c in row
145
+ if c.value != None and c.data_type == 'n' ]
146
+ return values
147
+
148
+ def wstrans(wsname):
149
+ 'Translates workspace names'
150
+ res = '_'+wsname.replace("'","").replace(' - ','_').replace(' ','_').replace('-','_')+'_'
151
+ return res.upper()
152
+
153
+ def findcoordinates(name):
154
+ '''Finds the cell references matching the codes in a LCR workbook from EBA
155
+
156
+ This is needed for the mapping of the raw data to the excel cell refereces.
157
+
158
+ input:
159
+ :name: Location of a excel sheeet
160
+
161
+ returns:
162
+ :coldf: Dataframe with mapping between excel column and EBA columns_code
163
+ :rowdf: Dataframe with row with mapping between excel row and EBS data row_code
164
+ '''
165
+ wb = load_workbook(name, read_only=True,data_only=True) # to read the spresdsheet first save as xml then write it again
166
+ allsheets = wb.sheetnames
167
+
168
+ colcodes=[]
169
+ rowcodes=[]
170
+
171
+ for wsname in allsheets:
172
+ ws=wb[wsname]
173
+ try:
174
+ #find the anchor for the row and columns id, the first
175
+ cell = [c for row in ws.rows for c in row if c.value and c.data_type == 's' and 'Row'== c.value][0]
176
+ # find the numeric values in the column below the anchor, only the digits and remenber python index starts with 0 while excels index starts with 1
177
+
178
+ rowcodes += [(wsname , c.value , c.row ) for r in ws.rows for c in r
179
+ if c.value and c.column == cell.column and c.row > cell.row and
180
+ ( c.data_type == 'n' or (c.data_type == 's' and c.value.isdigit()) )]
181
+
182
+ # finds the numeric values in the row at the right of the anchor.
183
+ # c.rows returns a generator (probably because te potential for a huge number) therefor the list(c.rows)
184
+ colcodes += [(wsname , c.value , get_column_letter(c.column ) ) for c in list(ws.rows)[cell.row-1]
185
+ if c.value and c.column > cell.column and (c.data_type == 'n' or (c.data_type == 's' and c.value.isdigit()))]
186
+ except: # Ok this ws did not have an ancor cell
187
+ pass
188
+ coldf = pd.DataFrame(colcodes,columns=['sheet','colcode','col'])
189
+ rowdf = pd.DataFrame(rowcodes,columns=['sheet','rowcode','row'])
190
+ return coldf,rowdf
191
+
192
+ def getexcelmodel(name):
193
+ ''' Creates a model instance from a excel sheet
194
+ SUM is replaced by SUM_EXCEL which is a function in the modelclass
195
+
196
+ In the excel formulars this function accepts ordinary operators and SUM in excel sheets
197
+
198
+ input:
199
+ :name: Location of a excel sheeet
200
+
201
+ returns:
202
+ :model: A model instance with the formulars of the excel sheet
203
+ :para: A list of values in the sheet which matches exogeneous variables in the model
204
+
205
+ '''
206
+ modelname = Path(name).stem
207
+ eqdic = findequations(name)
208
+ eqdic2 = {i : eq.replace('SUM(','SUM_EXCEL(') for i,eq in eqdic.items()}
209
+ fdic = {i : 'Frml xx '+eqdic2[i] + r' $ ' for i,eq in eqdic2.items()}
210
+ f = '\n'.join([eq for i,eq in fdic.items()])
211
+ _mmodel=mc.model(f,modelname=modelname)
212
+ zz = findvalues(name)
213
+ para = [z for z in zz if z[0] in _mmodel.exogene] # find all values which match a exogeneous variable in model
214
+ return _mmodel,para
215
+
216
+ #%% now functions related to running xlsheets
217
+
218
+
219
+ def indextrans(index):
220
+ '''
221
+ Transforms a period index to excel acceptable datatype
222
+
223
+
224
+ '''
225
+ out = [i.year if type(index) == pd.core.indexes.period.PeriodIndex
226
+ else int(i) for i in index]
227
+ return out
228
+
229
+ def df_to_sheet(name,df,wb,after=None):
230
+ '''
231
+ Dataframe to sheet
232
+
233
+ Args:
234
+ name (TYPE): DESCRIPTION.
235
+ df (TYPE): DESCRIPTION.
236
+ wb (TYPE): DESCRIPTION.
237
+ after (TYPE, optional): DESCRIPTION. Defaults to None.
238
+
239
+ Returns:
240
+ sht (TYPE): DESCRIPTION.
241
+
242
+ '''
243
+ try:
244
+ wb.sheets[name].delete()
245
+ except:
246
+ pass
247
+
248
+ try:
249
+ sht = wb.sheets.add(name,after=after)
250
+ except Exception as e :
251
+ print('no sheet added',str(e))
252
+ df_ = df.copy()
253
+ df_.index = indextrans(df.index)
254
+ sht.range('A1').value = df_.T
255
+ active_window = wb.app.api.ActiveWindow
256
+ active_window.FreezePanes = False
257
+ active_window.SplitColumn = 1
258
+ active_window.SplitRow = 1
259
+ active_window.FreezePanes = True
260
+ sht.autofit(axis="columns")
261
+ sht[(2,25)].select()
262
+ return sht
263
+
264
+ def obj_to_sheet(name,obj,wb,after=None):
265
+ '''
266
+ An python object to sheet
267
+
268
+ Args:
269
+ name (TYPE): DESCRIPTION.
270
+ obj (TYPE): DESCRIPTION.
271
+ wb (TYPE): DESCRIPTION.
272
+ after (TYPE, optional): DESCRIPTION. Defaults to None.
273
+
274
+ Returns:
275
+ None.
276
+
277
+ '''
278
+ # breakpoint()
279
+ try:
280
+ wb.sheets[name].delete()
281
+ except:
282
+ pass
283
+
284
+ try:
285
+ sht = wb.sheets.add(name,after=after)
286
+ except Exception as e:
287
+ print(str(e))
288
+ print('no sheet added ')
289
+ sht.range('A1').value=obj
290
+
291
+
292
+ def sheet_to_df(wb,name):
293
+ '''
294
+ Sheet to df
295
+
296
+ Args:
297
+ wb (TYPE): DESCRIPTION.
298
+ name (TYPE): DESCRIPTION.
299
+
300
+ Returns:
301
+ df (TYPE): DESCRIPTION.
302
+
303
+ '''
304
+ df = wb.sheets[name].range('A1').options(pd.DataFrame, expand='table').value.T
305
+ df.index = indextrans(df.index)
306
+ return df
307
+
308
+ def sheet_to_dict(wb,name,integers=None):
309
+ ''' transform the named sheet to a python dict. If we need a integer it has to be in the integer set'''
310
+
311
+ integers_ = {'max_iterations'} if isinstance(None,type(None)) else integers
312
+ try:
313
+ out = wb.sheets[name].range('A1').options(dict,expand='table').value
314
+ out2 = {k : int(v) if k in integers_ else v for k,v in out.items()}
315
+ except:
316
+ out2={}
317
+ return out2
318
+
319
+
320
+
321
+
322
+
323
+ if __name__ == '__main__':
324
+ testxls=Path('exceltest/lcrberegning2.xlsx')
325
+ mmodel,para = getexcelmodel(testxls)
326
+ eq=mmodel.equations
327
+ mmodel.draw('_LCR_C62',up=10,down=1,HR=0,pdf=1) # The LCR
328
+ mmodel.draw('_LCR_C25',up=4,down=1,pdf=1) # liquid assets
329
+ mmodel.draw('_LCR_C10',up=2,pdf=1) # Leel 1 covered bonds
330
+
331
+ c,r = findcoordinates(testxls)
332
+ xx = findequations(testxls)