Skip to content

Commit

Permalink
Merge pull request #51 from PolicyEngine/mapping
Browse files Browse the repository at this point in the history
Fix mapping bug
  • Loading branch information
nikhilwoodruff committed Apr 25, 2022
2 parents dede391 + b0df258 commit d6afa04
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.10.2] - 2022-04-25

### Fixed

* Adding a `target` entity to `IndividualSim.calc` now functions correctly when `target` has a different entity type than `variable`.
* Adds `MANIFEST.in` to the repo.

## [0.10.1] - 2022-04-24

### Fixed
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include openfisca_tools *
12 changes: 5 additions & 7 deletions openfisca_tools/hypothetical.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,22 +275,20 @@ def calc(
self.apply_reform(reform)
self.build()

if map_to is None and target is not None:
map_to = self.get_entity(target).key

period = period or self.year
entity = self.system.variables[var].entity
if target is not None:
target_entity = self.get_entity(target)
if target_entity.key != entity.key:
target = self.get_group(entity, target)
try:
result = self.simulation.calculate(var, period)
except:
try:
result = self.sim.calculate_add(var, period)
except:
result = self.simulation.calculate_divide(var, period)
if (
target is not None
and target not in self.situation_data[entity.plural]
):
map_to = self.get_entity(target).key
if map_to is not None:
result = self.map_to(result, entity.key, map_to)
entity = self.entities[map_to]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="OpenFisca-Tools",
version="0.10.1",
version="0.10.2",
author="PolicyEngine",
license="http://www.fsf.org/licensing/licenses/agpl-3.0.html",
url="https://github.com/policyengine/openfisca-tools",
Expand Down

0 comments on commit d6afa04

Please sign in to comment.