PolicyEngine / policyengine-core

Core microsimulation engine for PolicyEngine models. Forked from OpenFisca-Core.
https://policyengine.github.io/policyengine-core
GNU Affero General Public License v3.0
14 stars 19 forks source link

`ValueError` when specifying reforms using multiple period styles #248

Closed MaxGhenis closed 4 weeks ago

MaxGhenis commented 4 weeks ago

See https://colab.research.google.com/drive/1HCz8eYmgsHuXLE2MI9Wy6EPRJTHFrDjO#scrollTo=FJFklV92xjY6

reform = Reform.from_dict({
  "gov.irs.credits.ctc.refundable.fully_refundable": {
    "2024-01-01.2025-12-31": True
  },
  "gov.irs.credits.ctc.amount.base[0].amount": {
      "2023:10": 3000
  }
}, country_id="us")

reformed = Microsimulation(reform=reform)

throws

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[<ipython-input-5-89dc63569c72>](https://localhost:8080/#) in <cell line: 10>()
      8 }, country_id="us")
      9 
---> 10 reformed = Microsimulation(reform=reform)
     11 
     12 reformed.calc("refundable_ctc", period=2024).sum()

6 frames
[/usr/local/lib/python3.10/dist-packages/policyengine_core/periods/helpers.py](https://localhost:8080/#) in raise_error(value)
    137             ]
    138         )
--> 139         raise ValueError(message)
    140 
    141     if value == "ETERNITY" or value == config.ETERNITY:

ValueError: Expected a period (eg. '2017', '2017-01', '2017-01-01', ...); got: '2023:10'.
Learn more about legal period formats in OpenFisca:
<https://openfisca.org/doc/coding-the-legislation/35_periods.html#periods-in-simulations>.
MaxGhenis commented 4 weeks ago

Never mind, had to be year:2023:10 not 2023:10.