policyengine-core 0.1.4__tar.gz → 0.1.6__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 (31) hide show
  1. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/PKG-INFO +1 -1
  2. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/PolicyEngine_Core.egg-info/PKG-INFO +1 -1
  3. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/api/hypothetical.py +8 -9
  4. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/server.py +5 -2
  5. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/setup.py +1 -1
  6. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/PolicyEngine_Core.egg-info/SOURCES.txt +0 -0
  7. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/PolicyEngine_Core.egg-info/dependency_links.txt +0 -0
  8. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/PolicyEngine_Core.egg-info/requires.txt +0 -0
  9. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/PolicyEngine_Core.egg-info/top_level.txt +0 -0
  10. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/__init__.py +0 -0
  11. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/api/__init__.py +0 -0
  12. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/api/cloud_run.py +0 -0
  13. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/api/general.py +0 -0
  14. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/api/microsimulation.py +0 -0
  15. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/charts/__init__.py +0 -0
  16. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/charts/hypothetical/__init__.py +0 -0
  17. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/charts/hypothetical/varying.py +0 -0
  18. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/charts/hypothetical/waterfall.py +0 -0
  19. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/charts/population/__init__.py +0 -0
  20. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/charts/population/distributional.py +0 -0
  21. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/charts/population/poverty.py +0 -0
  22. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/charts/population/waterfall.py +0 -0
  23. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/metrics/__init__.py +0 -0
  24. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/metrics/hypothetical.py +0 -0
  25. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/metrics/population.py +0 -0
  26. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/reforms/__init__.py +0 -0
  27. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/reforms/utils.py +0 -0
  28. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/utils/__init__.py +0 -0
  29. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/utils/formatting.py +0 -0
  30. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/policyengine_core/utils/general.py +0 -0
  31. {PolicyEngine-Core-0.1.4 → PolicyEngine-Core-0.1.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PolicyEngine-Core
3
- Version: 0.1.4
3
+ Version: 0.1.6
4
4
  Summary: UNKNOWN
5
5
  Home-page: https://github.com/policyengine/policyengine-core
6
6
  Author: PolicyEngine
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PolicyEngine-Core
3
- Version: 0.1.4
3
+ Version: 0.1.6
4
4
  Summary: UNKNOWN
5
5
  Home-page: https://github.com/policyengine/policyengine-core
6
6
  Author: PolicyEngine
@@ -9,6 +9,7 @@ from openfisca_core.taxbenefitsystems.tax_benefit_system import (
9
9
  TaxBenefitSystem,
10
10
  )
11
11
  from openfisca_core.periods import period
12
+ from functools import partial
12
13
 
13
14
 
14
15
  class IndividualSim:
@@ -22,12 +23,14 @@ class IndividualSim:
22
23
  year (int, optional): The default year input. Defaults to 2020.
23
24
  """
24
25
  self.year = year
25
- self.reforms = reform
26
+ self.reform = reform
26
27
  self.system = self.tax_benefit_system()
27
28
  self.sim_builder = SimulationBuilder()
28
29
  self.entity_names = {var.key: var for var in self.system.entities}
29
- self.apply_reform(self.reforms)
30
- self.situation_data = {entity: {} for entity in self.entity_names}
30
+ self.apply_reform(self.reform)
31
+ self.situation_data = {
32
+ entity.plural: {} for entity in self.system.entities
33
+ }
31
34
  self.varying = False
32
35
  self.num_points = None
33
36
 
@@ -35,11 +38,7 @@ class IndividualSim:
35
38
 
36
39
  for entity in self.entity_names:
37
40
  setattr(
38
- self,
39
- f"add_{entity}",
40
- lambda *args, **kwargs: self.add_data(
41
- *args, **kwargs, entity=entity
42
- ),
41
+ self, f"add_{entity}", partial(self.add_data, entity=entity)
43
42
  )
44
43
 
45
44
  def build(self):
@@ -61,7 +60,7 @@ class IndividualSim:
61
60
 
62
61
  def add_data(
63
62
  self,
64
- entity: str = "person",
63
+ entity: str = None,
65
64
  name: str = None,
66
65
  input_period: str = None,
67
66
  auto_period: str = True,
@@ -36,7 +36,7 @@ class PolicyEngine:
36
36
  self.app = Flask(
37
37
  type(self).__name__,
38
38
  static_url_path="",
39
- static_folder=self.static_folder,
39
+ static_folder=str(self.static_folder),
40
40
  )
41
41
  self.app.logger.info("Initialising server.")
42
42
  CORS(self.app)
@@ -50,7 +50,8 @@ class PolicyEngine:
50
50
  # Forward client endpoints to React and API endpoints to Flask
51
51
 
52
52
  def static_site():
53
- return send_from_directory(self.static_folder, "index.html")
53
+ print(str(self.static_folder))
54
+ return send_from_directory(str(self.static_folder), "index.html")
54
55
 
55
56
  for route in self.client_endpoints:
56
57
  static_site = self.app.route(route)(static_site)
@@ -70,10 +71,12 @@ class PolicyEngine:
70
71
  def pass_params_and_cache(fn):
71
72
  def new_fn(*args, **kwargs):
72
73
  params = {**request.args, **(request.json or {})}
74
+ cached_result = None
73
75
  if self.cache is not None:
74
76
  cached_result = get_cached_result(
75
77
  params, fn.__name__, self.version, self.cache
76
78
  )
79
+ if cached_result is not None:
77
80
  return cached_result
78
81
  else:
79
82
  return fn(*args, params=params, **kwargs)
@@ -3,7 +3,7 @@ from pathlib import Path
3
3
 
4
4
  setup(
5
5
  name="PolicyEngine-Core",
6
- version="0.1.4",
6
+ version="0.1.6",
7
7
  author="PolicyEngine",
8
8
  license="http://www.fsf.org/licensing/licenses/agpl-3.0.html",
9
9
  url="https://github.com/policyengine/policyengine-core",