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

feat: merge holders with storage #1167

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
38 changes: 0 additions & 38 deletions .github/get-numpy-version.py

This file was deleted.

26 changes: 1 addition & 25 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,30 +113,6 @@ jobs:
- name: Run Extension Template tests
run: make test-extension

check-numpy:
runs-on: ubuntu-22.04
needs: [ build ]
env:
TERM: xterm-256color

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.10.6

- name: Cache build
id: restore-build
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}

- name: Check NumPy typing against latest 3 minor versions
run: for i in {1..3}; do VERSION=$(${GITHUB_WORKSPACE}/.github/get-numpy-version.py prev) && pip install numpy==$VERSION && make check-types; done

lint-files:
runs-on: ubuntu-22.04
needs: [ build ]
Expand Down Expand Up @@ -165,7 +141,7 @@ jobs:

check-version:
runs-on: ubuntu-22.04
needs: [ test-core, test-country-template, test-extension-template, check-numpy, lint-files ] # Last job to run
needs: [ test-core, test-country-template, test-extension-template, lint-files ] # Last job to run

steps:
- uses: actions/checkout@v2
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 41.1.0 [#1167](https://github.com/openfisca/openfisca-core/pull/1167)

#### New features

- Use `UserDict` to encapsulate the data model of the `data_storage` module.

#### Technical changes

- Add tests to `data_storage`.
- Add typing to `data_storage`.
- Add documentation to `data_storage`.

# 41.0.0 [#1189](https://github.com/openfisca/openfisca-core/pull/1189)

#### Breaking changes
Expand Down Expand Up @@ -101,6 +113,7 @@ using `pip freeze`) or with tools providing such features (`pipenv`, etc.).

- Drop support for OpenAPI specification v2 and prior.
- Users relying on OpenAPI v2 can use [Swagger Converter](https://converter.swagger.io/api/convert?url=OAS2_YAML_OR_JSON_URL) to migrate ([example](https://web.archive.org/web/20221103230822/https://converter.swagger.io/api/convert?url=https://api.demo.openfisca.org/latest/spec)).
>>>>>>> master

### 37.0.2 [#1170](https://github.com/openfisca/openfisca-core/pull/1170)

Expand Down
19 changes: 4 additions & 15 deletions openfisca_core/commons/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,7 @@

"""

# Official Public API

from .formulas import apply_thresholds, concat, switch # noqa: F401
from .misc import empty_clone, stringify_array # noqa: F401
from .rates import average_rate, marginal_rate # noqa: F401

__all__ = ["apply_thresholds", "concat", "switch"]
__all__ = ["empty_clone", "stringify_array", *__all__]
__all__ = ["average_rate", "marginal_rate", *__all__]

# Deprecated

from .dummy import Dummy # noqa: F401

__all__ = ["Dummy", *__all__]
from .dummy import Dummy
from .formulas import apply_thresholds, concat, switch
from .misc import empty_clone, stringify_array
from .rates import average_rate, marginal_rate
13 changes: 6 additions & 7 deletions openfisca_core/commons/formulas.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from typing import Any, Dict, Sequence, TypeVar
from openfisca_core.types import Array
from typing import Any, Sequence, TypeVar

import numpy

from openfisca_core.types import ArrayLike, Array

T = TypeVar("T")


def apply_thresholds(
input: Array[float],
thresholds: ArrayLike[float],
choices: ArrayLike[float],
thresholds: Array[float],
choices: Array[float],
) -> Array[float]:
"""Makes a choice based on an input and thresholds.

Expand Down Expand Up @@ -58,7 +57,7 @@ def apply_thresholds(
return numpy.select(condlist, choices)


def concat(this: ArrayLike[str], that: ArrayLike[str]) -> Array[str]:
def concat(this: Array[str], that: Array[str]) -> Array[str]:
"""Concatenates the values of two arrays.

Args:
Expand Down Expand Up @@ -88,7 +87,7 @@ def concat(this: ArrayLike[str], that: ArrayLike[str]) -> Array[str]:

def switch(
conditions: Array[Any],
value_by_condition: Dict[float, T],
value_by_condition: dict[float, T],
) -> Array[T]:
"""Mimicks a switch statement.

Expand Down
3 changes: 1 addition & 2 deletions openfisca_core/commons/misc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import TypeVar

from openfisca_core.types import Array
from typing import TypeVar

T = TypeVar("T")

Expand Down
9 changes: 4 additions & 5 deletions openfisca_core/commons/rates.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from openfisca_core.types import Array
from typing import Optional

import numpy

from openfisca_core.types import ArrayLike, Array


def average_rate(
target: Array[float],
varying: ArrayLike[float],
trim: Optional[ArrayLike[float]] = None,
varying: Array[float],
trim: Optional[Array[float]] = None,
) -> Array[float]:
"""Computes the average rate of a target net income.

Expand Down Expand Up @@ -64,7 +63,7 @@ def average_rate(
def marginal_rate(
target: Array[float],
varying: Array[float],
trim: Optional[ArrayLike[float]] = None,
trim: Optional[Array[float]] = None,
) -> Array[float]:
"""Computes the marginal rate of a target net income.

Expand Down
25 changes: 0 additions & 25 deletions openfisca_core/data_storage/__init__.py

This file was deleted.

65 changes: 0 additions & 65 deletions openfisca_core/data_storage/in_memory_storage.py

This file was deleted.

90 changes: 0 additions & 90 deletions openfisca_core/data_storage/on_disk_storage.py

This file was deleted.

Loading