Skip to content

Commit

Permalink
Remove irrelevant decimals added while casting
Browse files Browse the repository at this point in the history
  • Loading branch information
fpagnoux authored Aug 8, 2018
2 parents 791b8ae + 2094197 commit e3e2118
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

### 23.5.1 [#708](https://github.com/openfisca/openfisca-core/pull/708)

- Remove the irrelevant decimals that were added at the end of `float` results in the Web API and the test runner.
- These decimals were added while converting a Numpy `float32` to a regular 64-bits Python `float`.

For instance, the former Web API response extract:

```json
"tax_incentive": {
"2017-01": 333.3333435058594
}
```

becomes:

```json
"tax_incentive": {
"2017-01": 333.33334
}
```

## 23.5.0 [#705](https://github.com/openfisca/openfisca-core/pull/705)

* On the Web API, expose a welcome message (with a 300 code) on `/` instead of a 404 error.
Expand Down
5 changes: 2 additions & 3 deletions openfisca_core/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ def assert_near(value, target_value, absolute_error_margin = None, message = '',
else:
assert (target_value == value.decode()).all(), "Expected {}, got {}".format(target_value, value)
else:

target_value = np.array(target_value).astype(float)
value = np.array(value).astype(float)
target_value = np.array(target_value).astype(np.float32)
value = np.array(value).astype(np.float32)
diff = abs(target_value - value)

if absolute_error_margin is not None:
Expand Down
2 changes: 2 additions & 0 deletions openfisca_web_api_preview/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ def calculate():

if variable.value_type == Enum:
entity_result = result.decode()[entity_index].name
elif variable.value_type == float:
entity_result = float(str(result[entity_index])) # To turn the float32 into a regular float without adding confusing extra decimals. There must be a better way.
else:
entity_result = result.tolist()[entity_index]

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name = 'OpenFisca-Core',
version = '23.5.0',
version = '23.5.1',
author = 'OpenFisca Team',
author_email = 'contact@openfisca.org',
classifiers = [
Expand Down

0 comments on commit e3e2118

Please sign in to comment.