From 9e215a5a36cb4be7e9922bc30609d46be673802f Mon Sep 17 00:00:00 2001 From: Hamish Fraser Date: Mon, 13 May 2024 15:06:35 +1200 Subject: [PATCH] Added example script for running the situation examples --- CHANGELOG.md | 6 ++++++ .../situation_examples/__init__.py | 3 ++- openfisca_country_template/situation_examples/run.py | 12 ++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 openfisca_country_template/situation_examples/run.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 29db7322..17368e97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +### 7.1.3 [#149](https://github.com/openfisca/country-template/pull/149) + +* Technical improvement +* Details: + - Add `run.py` to situation examples, enables simple executable situation example for documentation. + ### 7.1.2 [#147](https://github.com/openfisca/country-template/pull/147) * Technical improvement diff --git a/openfisca_country_template/situation_examples/__init__.py b/openfisca_country_template/situation_examples/__init__.py index b1b7cfb4..33ae61a4 100644 --- a/openfisca_country_template/situation_examples/__init__.py +++ b/openfisca_country_template/situation_examples/__init__.py @@ -14,5 +14,6 @@ def parse(file_name): return json.loads(file.read()) -single = parse("single.json") couple = parse("couple.json") +housing = parse("housing.json") +single = parse("single.json") diff --git a/openfisca_country_template/situation_examples/run.py b/openfisca_country_template/situation_examples/run.py new file mode 100644 index 00000000..1cc1285b --- /dev/null +++ b/openfisca_country_template/situation_examples/run.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- + +from openfisca_country_template import CountryTaxBenefitSystem +from openfisca_core.simulation_builder import SimulationBuilder +from . import couple + +tax_benefit_system = CountryTaxBenefitSystem() +simulation_builder = SimulationBuilder() +simulation = simulation_builder.build_from_entities(tax_benefit_system, couple) + +print (simulation.calculate('total_taxes', '2017-01')) +print (simulation.calculate('total_benefits', '2017-01'))