Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added example script for running the situation examples #149

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion openfisca_country_template/situation_examples/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
12 changes: 12 additions & 0 deletions openfisca_country_template/situation_examples/run.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of this file is ambiguous and unclear. As I understand it, it is only an executable example of how to load situation examples. However its name, run, makes it sound as though it is the one way to access or build the examples.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the doc, “Python supports writing source code in UTF-8 by default”, are you sure this is necessary?


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'))
Loading