-
Notifications
You must be signed in to change notification settings - Fork 80
Description
Axes are a useful way of showing how variables interact with each other (for example, for multivariate observation).
OpenFisca's Python API already handles this. See, for example, Replicating a situation along axes.
However, the Web API does not know how to handle this. For example, if you run:
curl -X POST "https://api.demo.openfisca.org/latest/calculate" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"persons\":{\"Thomas\":{},\"Mauko\":{}},\"households\":{\"workshop\":{\"adults\":[\"Thomas\",\"Mauko\"],\"total_taxes\":{\"2025-03\":null}}},\"axes\":[[{\"count\":10,\"name\":\"salary\",\"min\":0,\"max\":10000,\"period\":\"2025-03\"}]]}"
You will get the following error:
Traceback (most recent call last):
File "/openfisca-core/openfisca_web_api/app.py", line 167, in calculate
result = handlers.calculate(tax_benefit_system, input_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openfisca-core/openfisca_web_api/handlers.py", line 26, in calculate
entity_index = population.get_index(entity_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openfisca-core/openfisca_core/populations/_core_population.py", line 258, in get_index
return self.ids.index(id)
^^^^^^^^^^^^^^^^^^
ValueError: 'workshop' is not in list
This happens because, upon expansion, entities are expanded the number of times specified in count
, and are given incremental names (in our case, workshop0
, workshop1
, ..., workshop9
).
Modelling a JSON response of calculating axes is not trivial, as it depends on two cases:
- Parallel: the results are 1-d or 2-d
- Perpendicular: the results are 3d+
This request is to implement the JSON serialisation for n-parallel axes expansion, as the corresponding result vectors can be naturally mapped to the current situation schema: entity_plural/entity_instance_id/openfisca_variable_name/period
.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status