modelflowib 2.80__tar.gz → 2.81__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 (50) hide show
  1. {modelflowib-2.80 → modelflowib-2.81}/PKG-INFO +14 -10
  2. {modelflowib-2.80 → modelflowib-2.81}/modelclass.py +92 -30
  3. {modelflowib-2.80 → modelflowib-2.81}/modelflowib.egg-info/PKG-INFO +14 -10
  4. {modelflowib-2.80 → modelflowib-2.81}/modelflowib.egg-info/requires.txt +12 -6
  5. {modelflowib-2.80 → modelflowib-2.81}/pyproject.toml +23 -11
  6. {modelflowib-2.80 → modelflowib-2.81}/README.md +0 -0
  7. {modelflowib-2.80 → modelflowib-2.81}/license.md +0 -0
  8. {modelflowib-2.80 → modelflowib-2.81}/modelBLfunk.py +0 -0
  9. {modelflowib-2.80 → modelflowib-2.81}/model_Excel.py +0 -0
  10. {modelflowib-2.80 → modelflowib-2.81}/model_cvx.py +0 -0
  11. {modelflowib-2.80 → modelflowib-2.81}/model_dynare.py +0 -0
  12. {modelflowib-2.80 → modelflowib-2.81}/model_financial_stability.py +0 -0
  13. {modelflowib-2.80 → modelflowib-2.81}/model_latex.py +0 -0
  14. {modelflowib-2.80 → modelflowib-2.81}/model_latex_class.py +0 -0
  15. {modelflowib-2.80 → modelflowib-2.81}/model_parquet_mixin.py +0 -0
  16. {modelflowib-2.80 → modelflowib-2.81}/modelconstruct.py +0 -0
  17. {modelflowib-2.80 → modelflowib-2.81}/modelconstruct_estimation.py +0 -0
  18. {modelflowib-2.80 → modelflowib-2.81}/modeldash.py +0 -0
  19. {modelflowib-2.80 → modelflowib-2.81}/modeldashboot.py +0 -0
  20. {modelflowib-2.80 → modelflowib-2.81}/modeldashsidebar.py +0 -0
  21. {modelflowib-2.80 → modelflowib-2.81}/modeldekom.py +0 -0
  22. {modelflowib-2.80 → modelflowib-2.81}/modeldiff.py +0 -0
  23. {modelflowib-2.80 → modelflowib-2.81}/modeldisplay.py +0 -0
  24. {modelflowib-2.80 → modelflowib-2.81}/modelestimation.py +0 -0
  25. {modelflowib-2.80 → modelflowib-2.81}/modelestimator_new.py +0 -0
  26. {modelflowib-2.80 → modelflowib-2.81}/modelflowib.egg-info/SOURCES.txt +0 -0
  27. {modelflowib-2.80 → modelflowib-2.81}/modelflowib.egg-info/dependency_links.txt +0 -0
  28. {modelflowib-2.80 → modelflowib-2.81}/modelflowib.egg-info/top_level.txt +0 -0
  29. {modelflowib-2.80 → modelflowib-2.81}/modelgrab.py +0 -0
  30. {modelflowib-2.80 → modelflowib-2.81}/modelgrabgdx.py +0 -0
  31. {modelflowib-2.80 → modelflowib-2.81}/modelgrabwf2.py +0 -0
  32. {modelflowib-2.80 → modelflowib-2.81}/modelhelp.py +0 -0
  33. {modelflowib-2.80 → modelflowib-2.81}/modelhtml.py +0 -0
  34. {modelflowib-2.80 → modelflowib-2.81}/modelinvert.py +0 -0
  35. {modelflowib-2.80 → modelflowib-2.81}/modeljupyter.py +0 -0
  36. {modelflowib-2.80 → modelflowib-2.81}/modeljupytermagic.py +0 -0
  37. {modelflowib-2.80 → modelflowib-2.81}/modelmacrograb.py +0 -0
  38. {modelflowib-2.80 → modelflowib-2.81}/modelmanipulation.py +0 -0
  39. {modelflowib-2.80 → modelflowib-2.81}/modelmf.py +0 -0
  40. {modelflowib-2.80 → modelflowib-2.81}/modelnet.py +0 -0
  41. {modelflowib-2.80 → modelflowib-2.81}/modelnewton.py +0 -0
  42. {modelflowib-2.80 → modelflowib-2.81}/modelnormalize.py +0 -0
  43. {modelflowib-2.80 → modelflowib-2.81}/modelpattern.py +0 -0
  44. {modelflowib-2.80 → modelflowib-2.81}/modelreport.py +0 -0
  45. {modelflowib-2.80 → modelflowib-2.81}/modelsolver_ng.py +0 -0
  46. {modelflowib-2.80 → modelflowib-2.81}/modeluserfunk.py +0 -0
  47. {modelflowib-2.80 → modelflowib-2.81}/modelvis.py +0 -0
  48. {modelflowib-2.80 → modelflowib-2.81}/modelwidget.py +0 -0
  49. {modelflowib-2.80 → modelflowib-2.81}/modelwidget_input.py +0 -0
  50. {modelflowib-2.80 → modelflowib-2.81}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: modelflowib
3
- Version: 2.80
3
+ Version: 2.81
4
4
  Summary: A tool to solve and manage dynamic economic and financial models
5
5
  Author-email: Ib Hansen <Ib.Hansen.Iv@gmail.com>
6
6
  License-Expression: MIT
@@ -20,22 +20,26 @@ Requires-Dist: numpy
20
20
  Requires-Dist: networkx
21
21
  Requires-Dist: tqdm
22
22
  Requires-Dist: scipy
23
- Requires-Dist: numexpr
24
- Requires-Dist: bottleneck
25
23
  Requires-Dist: XlsxWriter
26
24
  Requires-Dist: pyarrow
27
25
  Requires-Dist: tabulate
28
26
  Requires-Dist: openpyxl
29
27
  Requires-Dist: xarray
30
- Requires-Dist: cvxopt
31
- Requires-Dist: numba
32
- Requires-Dist: dash
33
- Requires-Dist: dash-bootstrap-components
34
- Requires-Dist: dash-interactive-graphviz
35
- Requires-Dist: lmfit
36
- Requires-Dist: jupyter
28
+ Requires-Dist: jinja2
29
+ Requires-Dist: ipython
37
30
  Requires-Dist: ipywidgets
38
31
  Requires-Dist: ipydatagrid
32
+ Requires-Dist: lmfit
33
+ Requires-Dist: statsmodels
34
+ Requires-Dist: numba; sys_platform != "emscripten"
35
+ Requires-Dist: cvxopt; sys_platform != "emscripten"
36
+ Requires-Dist: numexpr; sys_platform != "emscripten"
37
+ Requires-Dist: bottleneck; sys_platform != "emscripten"
38
+ Requires-Dist: dash; sys_platform != "emscripten"
39
+ Requires-Dist: dash-bootstrap-components; sys_platform != "emscripten"
40
+ Requires-Dist: dash-interactive-graphviz; sys_platform != "emscripten"
41
+ Requires-Dist: plotly; sys_platform != "emscripten"
42
+ Requires-Dist: jupyter; sys_platform != "emscripten"
39
43
  Provides-Extra: shiny
40
44
  Requires-Dist: shiny; extra == "shiny"
41
45
  Requires-Dist: shinywidgets; extra == "shiny"
@@ -73,6 +73,11 @@ from typing import Iterable
73
73
  import zipfile
74
74
  from functools import partial,cached_property,lru_cache
75
75
  from tqdm.auto import tqdm
76
+ if sys.platform == 'emscripten':
77
+ # a browser has no threads, so tqdm can not start its monitor thread. Set on the
78
+ # base class, which tqdm.auto and tqdm.notebook inherit it from
79
+ import tqdm as tqdm_module
80
+ tqdm_module.tqdm.monitor_interval = 0
76
81
  import operator
77
82
  from urllib.request import urlopen
78
83
  from io import BytesIO,StringIO
@@ -6317,36 +6322,41 @@ class Display_Mixin():
6317
6322
  from IPython.display import display, Markdown, HTML
6318
6323
  from pathlib import Path
6319
6324
  display(Markdown(text))
6325
+ rows = []
6320
6326
  for dir in sorted(Path(folder).glob('**')):
6321
6327
  # print(f'{dir=} {nocwd=}')
6322
6328
  if len(dir.parts) and str(dir.parts[-1]).startswith('.'):
6323
6329
  continue
6324
-
6330
+
6325
6331
  if dir == Path('.') and nocwd :
6326
6332
  continue
6327
-
6328
- filelist = (list(dir.glob('*readme.ipynb'))
6329
- + [f for f in sorted(dir.glob('*.ipynb'))
6333
+
6334
+ filelist = (list(dir.glob('*readme.ipynb'))
6335
+ + [f for f in sorted(dir.glob('*.ipynb'))
6330
6336
  if not f.stem.endswith('readme')])
6331
-
6332
- for i, notebook in enumerate(filelist):
6333
- # print(notebook)
6334
- if (not all) and (notebook.name.startswith('test') or notebook.name.startswith('Overview')):
6335
- continue
6336
- if i == 0:
6337
- blanks = ''.join(
6338
- ['&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;']*len(dir.parts))
6339
- if len(dir.parts):
6340
- display(HTML(f'{blanks}<b>{str(dir)}</b>'))
6341
- else:
6342
- display(
6343
- HTML(f'{blanks}<b>{str(Path.cwd().parts[-1])} (.)</b>'))
6344
6337
 
6345
- name = notebook.name.split('.')[0]
6338
+ if not all:
6339
+ filelist = [f for f in filelist
6340
+ if not (f.name.startswith('test') or f.name.startswith('Overview'))]
6341
+
6342
+ if not filelist:
6343
+ continue
6344
+
6345
+ indent = 2 * len(dir.parts) # indentation of this folder in em
6346
+ folder_name = str(dir) if len(dir.parts) else f'{str(Path.cwd().parts[-1])} (.)'
6347
+ rows.append(
6348
+ f'<tr><td colspan="2" style="text-align:left;padding:6px 12px 2px {indent}em">'
6349
+ f'<b>{folder_name}</b></td></tr>')
6350
+
6351
+ for notebook in filelist:
6346
6352
  # print(notebook)
6347
- display(HTML(
6348
- f'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{blanks} <a href="{notebook}" target="_blank">{name}</a>'))
6349
-
6353
+ name = notebook.name.split('.')[0]
6354
+ title = Display_Mixin._notebook_title(notebook)
6355
+ rows.append(
6356
+ f'<tr><td style="text-align:left;padding:2px 24px 2px {indent+2}em;white-space:nowrap">'
6357
+ f'<a href="{notebook}" target="_blank">{name}</a></td>'
6358
+ f'<td style="text-align:left;padding:2px 12px">{title}</td></tr>')
6359
+
6350
6360
  # try:
6351
6361
  # # Replace with your method of opening a notebook
6352
6362
  # # Example: Using jupyter command-line to open the notebook
@@ -6354,12 +6364,43 @@ class Display_Mixin():
6354
6364
  # subprocess.Popen(["jupyter", "notebook", str(notebook)])
6355
6365
  # except Exception as e:
6356
6366
  # print(f"Error opening notebook {notebook}: {e}")
6367
+ if rows:
6368
+ display(HTML(
6369
+ '<table style="border-collapse:collapse;border:none">'
6370
+ + ''.join(rows) + '</table>'))
6357
6371
 
6358
6372
 
6373
+ @staticmethod
6374
+ def _notebook_title(fname):
6375
+ '''Returns the first line starting with one or more # in the first cell of a jupyter notebook.
6376
+
6377
+ Returns an empty string if the notebook can not be read or no such line is found'''
6378
+
6379
+ import json
6380
+ from html import escape
6381
+
6382
+ try:
6383
+ with open(fname, 'rt', encoding='utf-8') as f:
6384
+ nb = json.load(f)
6385
+ cells = nb.get('cells', [])
6386
+ if not cells:
6387
+ return ''
6388
+ source = cells[0].get('source', '')
6389
+ lines = source.splitlines() if isinstance(source, str) else source
6390
+ for line in lines:
6391
+ stripped = line.strip()
6392
+ if stripped.startswith('#'):
6393
+ return escape(stripped.lstrip('#').strip())
6394
+ except Exception:
6395
+ ...
6396
+ return ''
6397
+
6359
6398
  @staticmethod
6360
6399
  def display_toc_this(pat='*',text='**Jupyter notebooks**',path='.',ext='ipynb',showext=False):
6361
-
6362
- '''In a jupyter notebook this function displays a clickable table of content in the folder pat with name in path'''
6400
+
6401
+ '''In a jupyter notebook this function displays a clickable table of content in the folder pat with name in path
6402
+
6403
+ For notebooks the first markdown header in the first cell is shown beside the name'''
6363
6404
 
6364
6405
  from IPython.display import display, Markdown, HTML
6365
6406
  from pathlib import Path
@@ -6367,10 +6408,18 @@ class Display_Mixin():
6367
6408
  display(Markdown(text))
6368
6409
  dir = Path(path)
6369
6410
  # print(dir,':')
6411
+ rows = []
6370
6412
  for fname in sorted(dir.glob(pat+'.'+ext)):
6371
6413
  name = fname.name if showext else fname.name.split('.')[0]
6414
+ title = Display_Mixin._notebook_title(fname) if ext == 'ipynb' else ''
6415
+ rows.append(
6416
+ f'<tr><td style="text-align:left;padding:2px 24px 2px 12px;white-space:nowrap">'
6417
+ f'<a href="{fname}" target="_blank">{name}</a></td>'
6418
+ f'<td style="text-align:left;padding:2px 12px">{title}</td></tr>')
6419
+ if rows:
6372
6420
  display(HTML(
6373
- f'&nbsp; &nbsp; <a href="{fname}" target="_blank">{name}</a>'))
6421
+ '<table style="border-collapse:collapse;border:none">'
6422
+ + ''.join(rows) + '</table>'))
6374
6423
 
6375
6424
 
6376
6425
  @staticmethod
@@ -6423,13 +6472,25 @@ class Display_Mixin():
6423
6472
  } catch (e) { /* ignore */ }
6424
6473
  """))
6425
6474
 
6426
- # Notebook 7 / JupyterLab: remove the scrolled-output max-height
6427
- # and the scrolled modifier wherever it is applied.
6475
+ # Notebook 7 / JupyterLab: the height is set on the output area of the
6476
+ # cell: .jp-mod-outputsScrolled .jp-Cell-outputArea {max-height: 24em}
6477
+ # height:auto also undoes a height the user has dragged in place, as an
6478
+ # important declaration wins over an inline style
6428
6479
  display(HTML("""
6429
6480
  <style id="mf-scroll-off">
6481
+ .jp-mod-outputsScrolled .jp-Cell-outputArea {
6482
+ max-height: none !important;
6483
+ height: auto !important;
6484
+ overflow-y: visible !important;
6485
+ resize: none !important;
6486
+ }
6430
6487
  .jp-OutputArea-output.jp-OutputArea-output { max-height: none !important; }
6431
- .jp-mod-outputsScrolled .jp-OutputArea-child {
6488
+ /* Classic Notebook (<=6) sets height, not max-height, on output_scroll */
6489
+ .output_scroll {
6490
+ height: auto !important;
6432
6491
  max-height: none !important;
6492
+ overflow: visible !important;
6493
+ box-shadow: none !important;
6433
6494
  }
6434
6495
  </style>
6435
6496
  """))
@@ -6454,11 +6515,12 @@ class Display_Mixin():
6454
6515
  } catch (e) { /* ignore */ }
6455
6516
  """))
6456
6517
 
6457
- # Remove the override stylesheet we injected above, if present.
6518
+ # Remove the override stylesheets we injected above, there is one for
6519
+ # each cell where scroll_off has been run
6458
6520
  display(Javascript("""
6459
6521
  try {
6460
- var s = document.getElementById('mf-scroll-off');
6461
- if (s) { s.parentNode.removeChild(s); }
6522
+ document.querySelectorAll('#mf-scroll-off').forEach(
6523
+ function (s) { s.parentNode.removeChild(s); });
6462
6524
  } catch (e) { /* ignore */ }
6463
6525
  """))
6464
6526
  except Exception as e:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: modelflowib
3
- Version: 2.80
3
+ Version: 2.81
4
4
  Summary: A tool to solve and manage dynamic economic and financial models
5
5
  Author-email: Ib Hansen <Ib.Hansen.Iv@gmail.com>
6
6
  License-Expression: MIT
@@ -20,22 +20,26 @@ Requires-Dist: numpy
20
20
  Requires-Dist: networkx
21
21
  Requires-Dist: tqdm
22
22
  Requires-Dist: scipy
23
- Requires-Dist: numexpr
24
- Requires-Dist: bottleneck
25
23
  Requires-Dist: XlsxWriter
26
24
  Requires-Dist: pyarrow
27
25
  Requires-Dist: tabulate
28
26
  Requires-Dist: openpyxl
29
27
  Requires-Dist: xarray
30
- Requires-Dist: cvxopt
31
- Requires-Dist: numba
32
- Requires-Dist: dash
33
- Requires-Dist: dash-bootstrap-components
34
- Requires-Dist: dash-interactive-graphviz
35
- Requires-Dist: lmfit
36
- Requires-Dist: jupyter
28
+ Requires-Dist: jinja2
29
+ Requires-Dist: ipython
37
30
  Requires-Dist: ipywidgets
38
31
  Requires-Dist: ipydatagrid
32
+ Requires-Dist: lmfit
33
+ Requires-Dist: statsmodels
34
+ Requires-Dist: numba; sys_platform != "emscripten"
35
+ Requires-Dist: cvxopt; sys_platform != "emscripten"
36
+ Requires-Dist: numexpr; sys_platform != "emscripten"
37
+ Requires-Dist: bottleneck; sys_platform != "emscripten"
38
+ Requires-Dist: dash; sys_platform != "emscripten"
39
+ Requires-Dist: dash-bootstrap-components; sys_platform != "emscripten"
40
+ Requires-Dist: dash-interactive-graphviz; sys_platform != "emscripten"
41
+ Requires-Dist: plotly; sys_platform != "emscripten"
42
+ Requires-Dist: jupyter; sys_platform != "emscripten"
39
43
  Provides-Extra: shiny
40
44
  Requires-Dist: shiny; extra == "shiny"
41
45
  Requires-Dist: shinywidgets; extra == "shiny"
@@ -6,22 +6,28 @@ numpy
6
6
  networkx
7
7
  tqdm
8
8
  scipy
9
- numexpr
10
- bottleneck
11
9
  XlsxWriter
12
10
  pyarrow
13
11
  tabulate
14
12
  openpyxl
15
13
  xarray
16
- cvxopt
14
+ jinja2
15
+ ipython
16
+ ipywidgets
17
+ ipydatagrid
18
+ lmfit
19
+ statsmodels
20
+
21
+ [:sys_platform != "emscripten"]
17
22
  numba
23
+ cvxopt
24
+ numexpr
25
+ bottleneck
18
26
  dash
19
27
  dash-bootstrap-components
20
28
  dash-interactive-graphviz
21
- lmfit
29
+ plotly
22
30
  jupyter
23
- ipywidgets
24
- ipydatagrid
25
31
 
26
32
  [shiny]
27
33
  shiny
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "modelflowib" # PyPI distribution name
7
- version = "2.80" # OVERWRITTEN at build time from MF_VERSION
7
+ version = "2.81" # OVERWRITTEN at build time from MF_VERSION
8
8
  # (set_pyproject_version.py / make_pip.py -v)
9
9
  description = "A tool to solve and manage dynamic economic and financial models"
10
10
  readme = "README.md"
@@ -18,8 +18,15 @@ classifiers = [
18
18
  "Operating System :: OS Independent",
19
19
  ]
20
20
 
21
- # PyPI dependencies (pip names). Carried over from the previous make_pip.py.
21
+ # PyPI dependencies (pip names).
22
+ #
23
+ # The ones marked `sys_platform != "emscripten"` have no wasm build, or need a web
24
+ # server, so they can not be installed in a browser (JupyterLite/Pyodide). pip on a
25
+ # desktop installs them as before; micropip in the browser skips them. That makes
26
+ # `piplite.install("modelflowib")` work *with* its dependencies, so a notebook in
27
+ # JupyterLite needs no list of packages of its own.
22
28
  dependencies = [
29
+ # --- everywhere ---
23
30
  "pandas",
24
31
  "matplotlib",
25
32
  "seaborn",
@@ -28,22 +35,27 @@ dependencies = [
28
35
  "networkx",
29
36
  "tqdm",
30
37
  "scipy",
31
- "numexpr",
32
- "bottleneck",
33
38
  "XlsxWriter",
34
39
  "pyarrow",
35
40
  "tabulate",
36
41
  "openpyxl",
37
42
  "xarray",
38
- "cvxopt",
39
- "numba",
40
- "dash",
41
- "dash-bootstrap-components",
42
- "dash-interactive-graphviz",
43
- "lmfit",
44
- "jupyter",
43
+ "jinja2", # pandas .style, used by the report and vis tables
44
+ "ipython", # IPython.display, imported by most modules
45
45
  "ipywidgets",
46
46
  "ipydatagrid",
47
+ "lmfit", # modelestimation, modelestimator_new
48
+ "statsmodels", # modelestimation, modelestimator_new
49
+ # --- not in a browser ---
50
+ "numba; sys_platform != 'emscripten'",
51
+ "cvxopt; sys_platform != 'emscripten'",
52
+ "numexpr; sys_platform != 'emscripten'", # pandas accelerators
53
+ "bottleneck; sys_platform != 'emscripten'",
54
+ "dash; sys_platform != 'emscripten'", # needs a web server
55
+ "dash-bootstrap-components; sys_platform != 'emscripten'",
56
+ "dash-interactive-graphviz; sys_platform != 'emscripten'",
57
+ "plotly; sys_platform != 'emscripten'", # modeldashsidebar
58
+ "jupyter; sys_platform != 'emscripten'", # JupyterLite is the notebook there
47
59
  ]
48
60
 
49
61
  [project.optional-dependencies]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes