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

Document that we expect axis count to be an int #925

Merged
merged 2 commits into from
Jan 31, 2020
Merged
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

### 34.6.9 [#925](https://github.com/openfisca/openfisca-core/pull/925)

#### Documentation

- Annotates the expected type of the axis count in `SimulationBuilder`.

### 34.6.8 [#936](https://github.com/openfisca/openfisca-core/pull/936)

#### Technical change
Expand Down
21 changes: 14 additions & 7 deletions openfisca_core/simulation_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ def expand_axes(self):
if len(self.axes) == 1 and len(self.axes[0]):
parallel_axes = self.axes[0]
first_axis = parallel_axes[0]
axis_count = first_axis['count']
axis_count: int = first_axis['count']
axis_entity = self.get_variable_entity(first_axis['name'])
axis_entity_step_size = self.entity_counts[axis_entity.plural]
# Distribute values along axes
Expand All @@ -512,16 +512,23 @@ def expand_axes(self):
array = self.get_input(axis_name, axis_period)
if array is None:
array = variable.default_array(axis_count * axis_entity_step_size)
array[axis_index:: axis_entity_step_size] = np.linspace(axis['min'], axis['max'], axis_count)
array[axis_index:: axis_entity_step_size] = np.linspace(
axis['min'],
axis['max'],
num = axis_count,
)
# Set input
self.input_buffer[axis_name][str(axis_period)] = array
else:
first_axes_count: List[int] = (
parallel_axes[0]["count"]
for parallel_axes
in self.axes
)
axes_linspaces = [
np.linspace(0, first_axis['count'] - 1, first_axis['count'])
for first_axis in (
parallel_axes[0]
for parallel_axes in self.axes
)
np.linspace(0, axis_count - 1, num = axis_count)
for axis_count
in first_axes_count
]
axes_meshes = np.meshgrid(*axes_linspaces)
for parallel_axes, mesh in zip(self.axes, axes_meshes):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

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