ModelFlowIb 2.64__tar.gz → 2.65__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 (54) hide show
  1. {modelflowib-2.64 → modelflowib-2.65}/ModelFlowIb.egg-info/PKG-INFO +1 -1
  2. {modelflowib-2.64 → modelflowib-2.65}/PKG-INFO +1 -1
  3. {modelflowib-2.64 → modelflowib-2.65}/modelhelp.py +126 -0
  4. {modelflowib-2.64 → modelflowib-2.65}/modelwidget_input.py +0 -3
  5. {modelflowib-2.64 → modelflowib-2.65}/pyproject.toml +1 -1
  6. {modelflowib-2.64 → modelflowib-2.65}/ModelFlowIb.egg-info/SOURCES.txt +0 -0
  7. {modelflowib-2.64 → modelflowib-2.65}/ModelFlowIb.egg-info/dependency_links.txt +0 -0
  8. {modelflowib-2.64 → modelflowib-2.65}/ModelFlowIb.egg-info/requires.txt +0 -0
  9. {modelflowib-2.64 → modelflowib-2.65}/ModelFlowIb.egg-info/top_level.txt +0 -0
  10. {modelflowib-2.64 → modelflowib-2.65}/modelBLfunk.py +0 -0
  11. {modelflowib-2.64 → modelflowib-2.65}/model_Excel.py +0 -0
  12. {modelflowib-2.64 → modelflowib-2.65}/model_cvx.py +0 -0
  13. {modelflowib-2.64 → modelflowib-2.65}/model_doable.py +0 -0
  14. {modelflowib-2.64 → modelflowib-2.65}/model_dynare.py +0 -0
  15. {modelflowib-2.64 → modelflowib-2.65}/model_financial_stability.py +0 -0
  16. {modelflowib-2.64 → modelflowib-2.65}/model_ifrs9.py +0 -0
  17. {modelflowib-2.64 → modelflowib-2.65}/model_latex.py +0 -0
  18. {modelflowib-2.64 → modelflowib-2.65}/model_latex_class.py +0 -0
  19. {modelflowib-2.64 → modelflowib-2.65}/model_run_numba.py +0 -0
  20. {modelflowib-2.64 → modelflowib-2.65}/modelclass.py +0 -0
  21. {modelflowib-2.64 → modelflowib-2.65}/modelclass2.py +0 -0
  22. {modelflowib-2.64 → modelflowib-2.65}/modelconstruct.py +0 -0
  23. {modelflowib-2.64 → modelflowib-2.65}/modeldash.py +0 -0
  24. {modelflowib-2.64 → modelflowib-2.65}/modeldashboot.py +0 -0
  25. {modelflowib-2.64 → modelflowib-2.65}/modeldashsidebar.py +0 -0
  26. {modelflowib-2.64 → modelflowib-2.65}/modeldekom.py +0 -0
  27. {modelflowib-2.64 → modelflowib-2.65}/modeldiff.py +0 -0
  28. {modelflowib-2.64 → modelflowib-2.65}/modeldisplay.py +0 -0
  29. {modelflowib-2.64 → modelflowib-2.65}/modelestimation.py +0 -0
  30. {modelflowib-2.64 → modelflowib-2.65}/modelfeedback.py +0 -0
  31. {modelflowib-2.64 → modelflowib-2.65}/modelgrab.py +0 -0
  32. {modelflowib-2.64 → modelflowib-2.65}/modelgrabwf2.py +0 -0
  33. {modelflowib-2.64 → modelflowib-2.65}/modelinvert.py +0 -0
  34. {modelflowib-2.64 → modelflowib-2.65}/modeljupyter.py +0 -0
  35. {modelflowib-2.64 → modelflowib-2.65}/modeljupytermagic.py +0 -0
  36. {modelflowib-2.64 → modelflowib-2.65}/modelmacrograb.py +0 -0
  37. {modelflowib-2.64 → modelflowib-2.65}/modelmanipulation.py +0 -0
  38. {modelflowib-2.64 → modelflowib-2.65}/modelmf.py +0 -0
  39. {modelflowib-2.64 → modelflowib-2.65}/modelnet.py +0 -0
  40. {modelflowib-2.64 → modelflowib-2.65}/modelnewton.py +0 -0
  41. {modelflowib-2.64 → modelflowib-2.65}/modelnormalize.py +0 -0
  42. {modelflowib-2.64 → modelflowib-2.65}/modelpattern.py +0 -0
  43. {modelflowib-2.64 → modelflowib-2.65}/modelpatternrev.py +0 -0
  44. {modelflowib-2.64 → modelflowib-2.65}/modelreport.py +0 -0
  45. {modelflowib-2.64 → modelflowib-2.65}/modelsandbox.py +0 -0
  46. {modelflowib-2.64 → modelflowib-2.65}/modelsandbox_Mixin.py +0 -0
  47. {modelflowib-2.64 → modelflowib-2.65}/modeltodo.py +0 -0
  48. {modelflowib-2.64 → modelflowib-2.65}/modeluserfunk.py +0 -0
  49. {modelflowib-2.64 → modelflowib-2.65}/modeluserfunk_old.py +0 -0
  50. {modelflowib-2.64 → modelflowib-2.65}/modelvis.py +0 -0
  51. {modelflowib-2.64 → modelflowib-2.65}/modelwidget.py +0 -0
  52. {modelflowib-2.64 → modelflowib-2.65}/modelwidget_input_old.py +0 -0
  53. {modelflowib-2.64 → modelflowib-2.65}/modelwidget_shinypy.py +0 -0
  54. {modelflowib-2.64 → modelflowib-2.65}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ModelFlowIb
3
- Version: 2.64
3
+ Version: 2.65
4
4
  Summary: A tool to solve and manage dynamic economic models
5
5
  Author-email: Ib Hansen <your@email.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ModelFlowIb
3
- Version: 2.64
3
+ Version: 2.65
4
4
  Summary: A tool to solve and manage dynamic economic models
5
5
  Author-email: Ib Hansen <your@email.com>
6
6
  License: MIT
@@ -371,7 +371,133 @@ def debug_var(*args, **kwargs):
371
371
  if starstar_note:
372
372
  print(f" (source included {starstar_note})")
373
373
 
374
+ def build_sorted_bond_desc_dict(var_names):
375
+ """
376
+ Build an ordered dictionary mapping variable names to human-readable bond descriptions.
377
+
378
+ The function expects variable names to follow a naming convention where the
379
+ relevant bond information appears after a double underscore, for example:
380
+
381
+ PREFIX__10_YEAR_DOM
382
+ PREFIX__5_YEAR_USD
383
+
384
+ From this suffix, the function extracts:
385
+ - maturity: the first element, interpreted as an integer number of years
386
+ - currency: the third element, expected to be ``DOM`` or another currency code
387
+
388
+ It then creates descriptions such as:
389
+ - ``"10 year domestic bond"``
390
+ - ``"5 year USD bond"``
391
+
392
+ The returned dictionary is sorted first by currency, with domestic bonds
393
+ appearing before foreign-currency bonds, and then by maturity in ascending order.
394
+
395
+ Parameters
396
+ ----------
397
+ var_names : iterable of str
398
+ Collection of variable names formatted like ``PREFIX__<maturity>_YEAR_<currency>``.
399
+
400
+ Returns
401
+ -------
402
+ dict
403
+ An ordered dictionary-like mapping from each variable name to its
404
+ generated description. In Python 3.7 and later, the standard ``dict``
405
+ preserves insertion order.
406
+
407
+ Raises
408
+ ------
409
+ IndexError
410
+ If a variable name does not contain the expected ``"__"`` separator or
411
+ does not have enough underscore-separated parts after it.
412
+ ValueError
413
+ If the maturity part cannot be converted to an integer.
414
+
415
+ Example
416
+ -------
417
+ >>> build_sorted_bond_desc_dict(["BOND__10_YEAR_DOM", "BOND__5_YEAR_USD", "BOND__2_YEAR_DOM"])
418
+ {
419
+ "BOND__2_YEAR_DOM": "2 year domestic bond",
420
+ "BOND__10_YEAR_DOM": "10 year domestic bond",
421
+ "BOND__5_YEAR_USD": "5 year USD bond"
422
+ }
423
+ """
424
+ parsed = []
425
+
426
+ for v in var_names:
427
+ tail = v.split('__')[1] # e.g. '10_YEAR_DOM'
428
+ parts = tail.split('_') # ['10', 'YEAR', 'DOM']
429
+
430
+ maturity = int(parts[0]) # numeric for sorting
431
+ currency = parts[2].lower() # dom or usd
432
+
433
+ currency_label = 'domestic' if currency == 'dom' else currency.upper()
434
+ description = f"{maturity} year {currency_label} bond"
435
+
436
+ # sort key: domestic first (0), then usd (1), then maturity
437
+ currency_order = 0 if currency == 'dom' else 1
438
+
439
+ parsed.append((currency_order, maturity, v, description))
440
+
441
+ # Sort by currency first, then maturity
442
+ parsed.sort()
443
+
444
+ # Build ordered dict (normal dict preserves order in Python 3.7+)
445
+ return {v: desc for _, _, v, desc in parsed}
374
446
 
447
+ def build_sorted_rate_desc_dict(var_names):
448
+ """
449
+ Build an ordered dictionary mapping interest-rate variable names to
450
+ human-readable bond interest rate descriptions.
451
+
452
+ Variable names are expected to end with ``__<maturity>``. If the part
453
+ before the final separator ends with ``_<CCY>``, where ``<CCY>`` is a
454
+ 3-letter alphabetic currency mnemonic, that mnemonic is used as the
455
+ currency label. Otherwise, the bond is treated as domestic-currency
456
+ denominated.
457
+
458
+ The result is sorted with domestic bonds first, then foreign-currency
459
+ bonds alphabetically by currency mnemonic, and then by maturity.
460
+
461
+ Parameters
462
+ ----------
463
+ var_names : iterable of str
464
+ Variable names such as ``interest_rate__10``,
465
+ ``interest_rate_USD__5``, or ``interest_rate_EUR__2``.
466
+
467
+ Returns
468
+ -------
469
+ dict
470
+ Ordered mapping from variable names to descriptions.
471
+
472
+ Raises
473
+ ------
474
+ IndexError
475
+ If a variable name does not contain ``"__"``.
476
+ ValueError
477
+ If the maturity suffix cannot be parsed as an integer.
478
+ """
479
+ parsed = []
480
+
481
+ for v in var_names:
482
+ left, maturity = v.rsplit('__', 1)
483
+ maturity = int(maturity)
484
+
485
+ suffix = left.rsplit('_', 1)[-1]
486
+ if len(suffix) == 3 and suffix.isalpha():
487
+ currency = suffix.upper()
488
+ currency_order = 1
489
+ currency_label = currency
490
+ else:
491
+ currency = ''
492
+ currency_order = 0
493
+ currency_label = 'domestic'
494
+
495
+ description = f"{maturity} year {currency_label} bond interest rate"
496
+ parsed.append((currency_order, currency, maturity, v, description))
497
+
498
+ parsed.sort()
499
+
500
+ return {v: desc for _, _, _, v, desc in parsed}
375
501
 
376
502
 
377
503
  if __name__ == '__main__':
@@ -565,9 +565,6 @@ class sheetwidget(SingleWidgetBase):
565
565
  raise ValueError(
566
566
  "Provide either both 'update_col' and 'update_index', or 'update_df'."
567
567
  )
568
-
569
-
570
-
571
568
 
572
569
  self.dec = int(self.content.get("dec", 2))
573
570
  self.transpose = bool(self.widgetdef.get("transpose", True))
@@ -7,7 +7,7 @@ where = ["."]
7
7
 
8
8
  [project]
9
9
  name = "ModelFlowIb"
10
- version = "2.64"
10
+ version = "2.65"
11
11
  description = "A tool to solve and manage dynamic economic models"
12
12
  authors = [{name = "Ib Hansen", email = "your@email.com"}]
13
13
  license = { text = "MIT" }
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
File without changes