policyengine-core 3.5.3__tar.gz → 3.6.2__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 (200) hide show
  1. {policyengine_core-3.5.3/policyengine_core.egg-info → policyengine_core-3.6.2}/PKG-INFO +1 -1
  2. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/data/dataset.py +1 -1
  3. policyengine_core-3.6.2/policyengine_core/simulations/sim_macro_cache.py +84 -0
  4. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/simulations/simulation.py +43 -69
  5. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/taxbenefitsystems/tax_benefit_system.py +2 -1
  6. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/types/data_types/arrays.py +1 -1
  7. {policyengine_core-3.5.3 → policyengine_core-3.6.2/policyengine_core.egg-info}/PKG-INFO +1 -1
  8. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core.egg-info/SOURCES.txt +1 -0
  9. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/setup.py +1 -1
  10. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/LICENSE +0 -0
  11. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/MANIFEST.in +0 -0
  12. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/README.md +0 -0
  13. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/__init__.py +0 -0
  14. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/charts/__init__.py +0 -0
  15. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/charts/api.py +0 -0
  16. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/charts/bar.py +0 -0
  17. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/charts/formatting.py +0 -0
  18. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/commons/__init__.py +0 -0
  19. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/commons/formulas.py +0 -0
  20. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/commons/misc.py +0 -0
  21. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/commons/rates.py +0 -0
  22. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/__init__.py +0 -0
  23. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/constants.py +0 -0
  24. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/data/__init__.py +0 -0
  25. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/data/datasets/__init__.py +0 -0
  26. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/data/datasets/country_template_dataset.py +0 -0
  27. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/entities.py +0 -0
  28. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/modelled_policies.yaml +0 -0
  29. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/parameters/benefits/basic_income.yaml +0 -0
  30. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/parameters/benefits/housing_allowance.yaml +0 -0
  31. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/parameters/benefits/index.yaml +0 -0
  32. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/parameters/benefits/parenting_allowance/amount.yaml +0 -0
  33. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/parameters/benefits/parenting_allowance/income_threshold.yaml +0 -0
  34. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/parameters/general/age_of_majority.yaml +0 -0
  35. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/parameters/general/age_of_retirement.yaml +0 -0
  36. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/parameters/taxes/housing_tax.yaml +0 -0
  37. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/parameters/taxes/income_tax_rate.yaml +0 -0
  38. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/parameters/taxes/social_security_contribution.yaml +0 -0
  39. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/reforms/__init__.py +0 -0
  40. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/reforms/add_dynamic_variable.py +0 -0
  41. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/reforms/add_new_tax.py +0 -0
  42. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/reforms/flat_social_security_contribution.py +0 -0
  43. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/reforms/modify_social_security_taxation.py +0 -0
  44. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/reforms/removal_basic_income.py +0 -0
  45. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/situation_examples/__init__.py +0 -0
  46. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/situation_examples/couple.json +0 -0
  47. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/situation_examples/housing.json +0 -0
  48. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/situation_examples/single.json +0 -0
  49. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/tests/age.yaml +0 -0
  50. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/tests/basic_income.yaml +0 -0
  51. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/tests/disposable_income.yaml +0 -0
  52. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/tests/housing_allowance.yaml +0 -0
  53. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/tests/housing_tax.yaml +0 -0
  54. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/tests/income_tax.yaml +0 -0
  55. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/tests/reforms/add_dynamic_variable.yaml +0 -0
  56. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/tests/reforms/add_new_tax.yaml +0 -0
  57. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/tests/reforms/modify_social_security_taxation.yaml +0 -0
  58. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/tests/situations/income_tax.yaml +0 -0
  59. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/tests/situations/parenting_allowance.yaml +0 -0
  60. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/tests/social_security_contribution.yaml +0 -0
  61. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/tests/test_microsimulation.py +0 -0
  62. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/variables/__init__.py +0 -0
  63. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/variables/benefits.py +0 -0
  64. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/variables/demographics.py +0 -0
  65. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/variables/housing.py +0 -0
  66. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/variables/ids.py +0 -0
  67. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/variables/income.py +0 -0
  68. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/variables/stats.py +0 -0
  69. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/country_template/variables/taxes.py +0 -0
  70. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/data/__init__.py +0 -0
  71. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/data_storage/__init__.py +0 -0
  72. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/data_storage/in_memory_storage.py +0 -0
  73. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/data_storage/on_disk_storage.py +0 -0
  74. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/data_structures/__init__.py +0 -0
  75. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/data_structures/parameter_metadata.py +0 -0
  76. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/data_structures/parameter_node_metadata.py +0 -0
  77. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/data_structures/reference.py +0 -0
  78. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/data_structures/unit.py +0 -0
  79. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/entities/__init__.py +0 -0
  80. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/entities/entity.py +0 -0
  81. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/entities/group_entity.py +0 -0
  82. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/entities/helpers.py +0 -0
  83. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/entities/role.py +0 -0
  84. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/enums/__init__.py +0 -0
  85. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/enums/config.py +0 -0
  86. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/enums/enum.py +0 -0
  87. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/enums/enum_array.py +0 -0
  88. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/errors/__init__.py +0 -0
  89. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/errors/cycle_error.py +0 -0
  90. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/errors/empty_argument_error.py +0 -0
  91. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/errors/nan_creation_error.py +0 -0
  92. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/errors/parameter_not_found_error.py +0 -0
  93. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/errors/parameter_parsing_error.py +0 -0
  94. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/errors/period_mismatch_error.py +0 -0
  95. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/errors/situation_parsing_error.py +0 -0
  96. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/errors/spiral_error.py +0 -0
  97. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/errors/variable_name_conflict_error.py +0 -0
  98. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/errors/variable_not_found_error.py +0 -0
  99. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/experimental/__init__.py +0 -0
  100. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/experimental/memory_config.py +0 -0
  101. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/extension_template/__init__.py +0 -0
  102. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/extension_template/local_benefit.py +0 -0
  103. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/extension_template/parameters/local_town/child_allowance/amount.yaml +0 -0
  104. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/extension_template/parameters/local_town/child_allowance/index.yaml +0 -0
  105. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/extension_template/parameters/local_town/index.yaml +0 -0
  106. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/extension_template/tests/local_benefit.yaml +0 -0
  107. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/holders/__init__.py +0 -0
  108. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/holders/helpers.py +0 -0
  109. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/holders/holder.py +0 -0
  110. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/model_api.py +0 -0
  111. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/parameters/__init__.py +0 -0
  112. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/parameters/at_instant_like.py +0 -0
  113. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/parameters/config.py +0 -0
  114. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/parameters/helpers.py +0 -0
  115. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/parameters/operations/__init__.py +0 -0
  116. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/parameters/operations/get_parameter.py +0 -0
  117. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/parameters/operations/homogenize_parameters.py +0 -0
  118. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/parameters/operations/interpolate_parameters.py +0 -0
  119. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/parameters/operations/propagate_parameter_metadata.py +0 -0
  120. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/parameters/operations/uprate_parameters.py +0 -0
  121. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/parameters/parameter.py +0 -0
  122. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/parameters/parameter_at_instant.py +0 -0
  123. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/parameters/parameter_node.py +0 -0
  124. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/parameters/parameter_node_at_instant.py +0 -0
  125. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/parameters/parameter_scale.py +0 -0
  126. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/parameters/parameter_scale_bracket.py +0 -0
  127. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/parameters/vectorial_parameter_node_at_instant.py +0 -0
  128. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/periods/__init__.py +0 -0
  129. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/periods/config.py +0 -0
  130. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/periods/helpers.py +0 -0
  131. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/periods/instant_.py +0 -0
  132. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/periods/period_.py +0 -0
  133. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/populations/__init__.py +0 -0
  134. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/populations/config.py +0 -0
  135. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/populations/group_population.py +0 -0
  136. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/populations/population.py +0 -0
  137. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/projectors/__init__.py +0 -0
  138. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/projectors/entity_to_person_projector.py +0 -0
  139. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/projectors/first_person_to_entity_projector.py +0 -0
  140. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/projectors/helpers.py +0 -0
  141. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/projectors/projector.py +0 -0
  142. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/projectors/unique_role_to_entity_projector.py +0 -0
  143. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/reforms/__init__.py +0 -0
  144. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/reforms/reform.py +0 -0
  145. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/scripts/__init__.py +0 -0
  146. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/scripts/assets/__init__.py +0 -0
  147. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/scripts/assets/index.html +0 -0
  148. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/scripts/policyengine_command.py +0 -0
  149. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/scripts/run_data.py +0 -0
  150. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/scripts/run_test.py +0 -0
  151. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/scripts/simulation_generator.py +0 -0
  152. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/simulations/__init__.py +0 -0
  153. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/simulations/helpers.py +0 -0
  154. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/simulations/individual_sim.py +0 -0
  155. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/simulations/microsimulation.py +0 -0
  156. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/simulations/simulation_builder.py +0 -0
  157. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/taxbenefitsystems/__init__.py +0 -0
  158. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/taxscales/__init__.py +0 -0
  159. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/taxscales/abstract_rate_tax_scale.py +0 -0
  160. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/taxscales/abstract_tax_scale.py +0 -0
  161. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/taxscales/amount_tax_scale_like.py +0 -0
  162. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/taxscales/helpers.py +0 -0
  163. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/taxscales/linear_average_rate_tax_scale.py +0 -0
  164. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/taxscales/marginal_amount_tax_scale.py +0 -0
  165. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/taxscales/marginal_rate_tax_scale.py +0 -0
  166. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/taxscales/rate_tax_scale_like.py +0 -0
  167. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/taxscales/single_amount_tax_scale.py +0 -0
  168. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/taxscales/tax_scale_like.py +0 -0
  169. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/tools/__init__.py +0 -0
  170. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/tools/simulation_dumper.py +0 -0
  171. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/tools/test_from_situation.py +0 -0
  172. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/tools/test_runner.py +0 -0
  173. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/tracers/__init__.py +0 -0
  174. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/tracers/computation_log.py +0 -0
  175. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/tracers/flat_trace.py +0 -0
  176. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/tracers/full_tracer.py +0 -0
  177. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/tracers/performance_log.py +0 -0
  178. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/tracers/simple_tracer.py +0 -0
  179. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/tracers/trace_node.py +0 -0
  180. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/tracers/tracing_parameter_node_at_instant.py +0 -0
  181. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/tracers/variable_graph.py +0 -0
  182. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/types/__init__.py +0 -0
  183. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/types/data_types/__init__.py +0 -0
  184. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/variables/__init__.py +0 -0
  185. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/variables/config.py +0 -0
  186. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/variables/defined_for.py +0 -0
  187. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/variables/helpers.py +0 -0
  188. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/variables/typing.py +0 -0
  189. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/variables/variable.py +0 -0
  190. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/warnings/__init__.py +0 -0
  191. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/warnings/libyaml_warning.py +0 -0
  192. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/warnings/memory_config_warning.py +0 -0
  193. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/warnings/tempfile_warning.py +0 -0
  194. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/weighting/__init__.py +0 -0
  195. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core/weighting/microdf.py +0 -0
  196. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core.egg-info/dependency_links.txt +0 -0
  197. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core.egg-info/entry_points.txt +0 -0
  198. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core.egg-info/requires.txt +0 -0
  199. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/policyengine_core.egg-info/top_level.txt +0 -0
  200. {policyengine_core-3.5.3 → policyengine_core-3.6.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: policyengine-core
3
- Version: 3.5.3
3
+ Version: 3.6.2
4
4
  Summary: Core microsimulation engine enabling country-specific policy models.
5
5
  Home-page: https://github.com/policyengine/policyengine-core
6
6
  Author: PolicyEngine
@@ -187,7 +187,7 @@ class Dataset:
187
187
  f"Could not save {variable} to {file}. The value is {value}."
188
188
  )
189
189
  elif self.data_format == Dataset.FLAT_FILE:
190
- values.to_csv(file, index=False)
190
+ data.to_csv(file, index=False)
191
191
 
192
192
  def load_dataset(
193
193
  self,
@@ -0,0 +1,84 @@
1
+ import shutil
2
+ from pathlib import Path
3
+ import h5py
4
+ from numpy.typing import ArrayLike
5
+ import importlib.metadata
6
+
7
+ from policyengine_core.taxbenefitsystems import TaxBenefitSystem
8
+
9
+
10
+ class Singleton(type):
11
+ _instances = {}
12
+
13
+ def __call__(cls, *args, **kwargs):
14
+ if cls not in cls._instances:
15
+ cls._instances[cls] = super(Singleton, cls).__call__(
16
+ *args, **kwargs
17
+ )
18
+ return cls._instances[cls]
19
+
20
+
21
+ class SimulationMacroCache(metaclass=Singleton):
22
+ def __init__(self, tax_benefit_system: TaxBenefitSystem):
23
+ self.core_version = importlib.metadata.version("policyengine-core")
24
+ self.country_package_metadata = (
25
+ tax_benefit_system.get_package_metadata()
26
+ )
27
+ self.country_version = self.country_package_metadata["version"]
28
+ self.cache_folder_path = None
29
+ self.cache_file_path = None
30
+
31
+ def set_cache_path(
32
+ self,
33
+ parent_path: [Path, str],
34
+ dataset_name: str,
35
+ variable_name: str,
36
+ period: str,
37
+ branch_name: str,
38
+ ):
39
+ storage_folder = Path(parent_path) / f"{dataset_name}_variable_cache"
40
+ self.cache_folder_path = storage_folder
41
+ storage_folder.mkdir(exist_ok=True)
42
+ self.cache_file_path = (
43
+ storage_folder / f"{variable_name}_{period}_{branch_name}.h5"
44
+ )
45
+
46
+ def set_cache_value(self, cache_file_path: Path, value: ArrayLike):
47
+ with h5py.File(cache_file_path, "w") as f:
48
+ f.create_dataset(
49
+ "metadata:core_version",
50
+ data=self.core_version,
51
+ )
52
+ f.create_dataset(
53
+ "metadata:country_version",
54
+ data=self.country_version,
55
+ )
56
+ f.create_dataset("values", data=value)
57
+
58
+ def get_cache_path(self):
59
+ return self.cache_file_path
60
+
61
+ def get_cache_value(self, cache_file_path: Path):
62
+ with h5py.File(cache_file_path, "r") as f:
63
+ # Validate both core version and country package metadata are up-to-date, otherwise flush the cache
64
+ if (
65
+ "metadata:core_version" in f
66
+ and "metadata:country_version" in f
67
+ ):
68
+ if (
69
+ f["metadata:core_version"][()].decode("utf-8")
70
+ != self.core_version
71
+ or f["metadata:country_version"][()].decode("utf-8")
72
+ != self.country_version
73
+ ):
74
+ f.close()
75
+ self.clear_cache(self.cache_folder_path)
76
+ return None
77
+ else:
78
+ f.close()
79
+ self.clear_cache(self.cache_folder_path)
80
+ return None
81
+ return f["values"][()]
82
+
83
+ def clear_cache(self, cache_folder_path: Path):
84
+ shutil.rmtree(cache_folder_path)
@@ -6,6 +6,7 @@ import numpy as np
6
6
  import pandas as pd
7
7
  from numpy.typing import ArrayLike
8
8
  import logging
9
+ from pathlib import Path
9
10
 
10
11
  from policyengine_core import commons, periods
11
12
  from policyengine_core.data.dataset import Dataset
@@ -21,9 +22,6 @@ from policyengine_core.tracers import (
21
22
  SimpleTracer,
22
23
  TracingParameterNodeAtInstant,
23
24
  )
24
- import h5py
25
- from pathlib import Path
26
- import shutil
27
25
 
28
26
  import json
29
27
 
@@ -36,6 +34,7 @@ from policyengine_core.tracers import SimpleTracer
36
34
  from policyengine_core.variables import Variable, QuantityType
37
35
  from policyengine_core.reforms.reform import Reform
38
36
  from policyengine_core.parameters import get_parameter
37
+ from policyengine_core.simulations.sim_macro_cache import SimulationMacroCache
39
38
 
40
39
 
41
40
  class Simulation:
@@ -606,11 +605,30 @@ class Simulation:
606
605
  if cached_array is not None:
607
606
  return cached_array
608
607
 
609
- cache_path = self._get_macro_cache(variable_name, str(period))
610
- if cache_path and cache_path.exists():
611
- value = self._get_macro_cache_value(cache_path)
612
- if value is not None:
613
- return self._get_macro_cache_value(cache_path)
608
+ smc = SimulationMacroCache(self.tax_benefit_system)
609
+
610
+ # Check if cache could be used, if available, check if path exists
611
+ is_cache_available = self.check_macro_cache(variable_name, str(period))
612
+ if is_cache_available:
613
+ smc.set_cache_path(
614
+ self.dataset.file_path.parent,
615
+ self.dataset.name,
616
+ variable_name,
617
+ str(period),
618
+ self.branch_name,
619
+ )
620
+ cache_path = smc.get_cache_path()
621
+ if cache_path.exists():
622
+ if (
623
+ not self.macro_cache_read
624
+ or self.tax_benefit_system.data_modified
625
+ ):
626
+ value = None
627
+ else:
628
+ value = smc.get_cache_value(cache_path)
629
+
630
+ if value is not None:
631
+ return value
614
632
 
615
633
  if variable.requires_computation_after is not None:
616
634
  if variable.requires_computation_after not in [
@@ -639,8 +657,8 @@ class Simulation:
639
657
  values = self.calculate_divide(variable_name, period)
640
658
 
641
659
  if alternate_period_handling:
642
- if cache_path is not None:
643
- self._set_macro_cache_value(cache_path, values)
660
+ if is_cache_available:
661
+ smc.set_cache_value(cache_path, values)
644
662
  return values
645
663
 
646
664
  self._check_period_consistency(period, variable)
@@ -738,8 +756,8 @@ class Simulation:
738
756
  f"RecursionError while calculating {variable_name} for period {period}. The full computation stack is:\n{stack_formatted}"
739
757
  )
740
758
 
741
- if cache_path is not None:
742
- self._set_macro_cache_value(cache_path, array)
759
+ if is_cache_available:
760
+ smc.set_cache_value(cache_path, array)
743
761
 
744
762
  return array
745
763
 
@@ -1396,77 +1414,33 @@ class Simulation:
1396
1414
 
1397
1415
  return json.loads(json.dumps(situation, cls=NpEncoder))
1398
1416
 
1399
- def _get_macro_cache(
1400
- self,
1401
- variable_name: str,
1402
- period: str,
1403
- ):
1417
+ def check_macro_cache(self, variable_name: str, period: str) -> bool:
1404
1418
  """
1405
- Get the cache location of a variable for a given period, if it exists.
1419
+ Check if the variable is able to have cached value
1406
1420
  """
1407
- if not self.is_over_dataset:
1408
- return None
1421
+ if (
1422
+ hasattr(self, "dataset")
1423
+ and self.dataset.data_format == Dataset.FLAT_FILE
1424
+ ):
1425
+ return False
1426
+
1427
+ if self.is_over_dataset:
1428
+ return True
1409
1429
 
1410
1430
  variable = self.tax_benefit_system.get_variable(variable_name)
1411
1431
  parameter_deps = variable.exhaustive_parameter_dependencies
1412
1432
 
1413
1433
  if parameter_deps is None:
1414
- return None
1434
+ return False
1415
1435
 
1416
1436
  for parameter in parameter_deps:
1417
1437
  param = get_parameter(
1418
1438
  self.tax_benefit_system.parameters, parameter
1419
1439
  )
1420
1440
  if param.modified:
1421
- return None
1422
-
1423
- storage_folder = (
1424
- self.dataset.file_path.parent
1425
- / f"{self.dataset.name}_variable_cache"
1426
- )
1427
- storage_folder.mkdir(exist_ok=True)
1441
+ return False
1428
1442
 
1429
- cache_file_path = (
1430
- storage_folder / f"{variable_name}_{period}_{self.branch_name}.h5"
1431
- )
1432
-
1433
- return cache_file_path
1434
-
1435
- def clear_macro_cache(self):
1436
- """
1437
- Clear the cache of all variables.
1438
- """
1439
- storage_folder = (
1440
- self.dataset.file_path.parent
1441
- / f"{self.dataset.name}_variable_cache"
1442
- )
1443
- if storage_folder.exists():
1444
- shutil.rmtree(storage_folder)
1445
-
1446
- def _get_macro_cache_value(
1447
- self,
1448
- cache_file_path: Path,
1449
- ):
1450
- """
1451
- Get the value of a variable from a cache file.
1452
- """
1453
- if not self.macro_cache_read or self.tax_benefit_system.data_modified:
1454
- return None
1455
- with h5py.File(cache_file_path, "r") as f:
1456
- return f["values"][()]
1457
-
1458
- def _set_macro_cache_value(
1459
- self,
1460
- cache_file_path: Path,
1461
- value: ArrayLike,
1462
- ):
1463
- """
1464
- Set the value of a variable in a cache file.
1465
- """
1466
- if not self.macro_cache_write or self.tax_benefit_system.data_modified:
1467
- return None
1468
- with h5py.File(cache_file_path, "w") as f:
1469
- f.create_dataset("values", data=value)
1443
+ return True
1470
1444
 
1471
1445
  def to_input_dataframe(
1472
1446
  self,
@@ -598,7 +598,8 @@ class TaxBenefitSystem:
598
598
 
599
599
  fallback_metadata = {
600
600
  "name": self.__class__.__name__,
601
- "version": "",
601
+ # For testing purposes
602
+ "version": "0.0.0",
602
603
  "repository_url": "",
603
604
  "location": "",
604
605
  }
@@ -3,7 +3,7 @@ from numpy.typing import NDArray as ArrayType
3
3
 
4
4
  T = TypeVar("T", bool, bytes, float, int, object, str)
5
5
 
6
- ArrayLike = ArrayType[Any] | Sequence[T]
6
+ ArrayLike = Sequence[T]
7
7
 
8
8
  """:obj:`typing.Generic`: Type of any castable to :class:`numpy.ndarray`.
9
9
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: policyengine-core
3
- Version: 3.5.3
3
+ Version: 3.6.2
4
4
  Summary: Core microsimulation engine enabling country-specific policy models.
5
5
  Home-page: https://github.com/policyengine/policyengine-core
6
6
  Author: PolicyEngine
@@ -152,6 +152,7 @@ policyengine_core/simulations/__init__.py
152
152
  policyengine_core/simulations/helpers.py
153
153
  policyengine_core/simulations/individual_sim.py
154
154
  policyengine_core/simulations/microsimulation.py
155
+ policyengine_core/simulations/sim_macro_cache.py
155
156
  policyengine_core/simulations/simulation.py
156
157
  policyengine_core/simulations/simulation_builder.py
157
158
  policyengine_core/taxbenefitsystems/__init__.py
@@ -47,7 +47,7 @@ dev_requirements = [
47
47
 
48
48
  setup(
49
49
  name="policyengine-core",
50
- version="3.5.3",
50
+ version="3.6.2",
51
51
  author="PolicyEngine",
52
52
  author_email="hello@policyengine.org",
53
53
  classifiers=[