Skip to content
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
55 changes: 47 additions & 8 deletions .github/workflows/merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,34 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-24.04, windows-2025]
numpy: [1.26.4]
# Patch version must be specified to avoid any cache confusion, since
# the cache key depends on the full Python version. If left unspecified,
# different patch versions could be allocated between jobs, and any
# such difference would lead to a cache not found error.
python: [3.11, 3.12, 3.13.9]
include:
- os: ubuntu-24.04
python: 3.11
numpy: 1.26.4
activate_command: source venv/bin/activate
- os: ubuntu-24.04
python: 3.12
numpy: 1.26.4
activate_command: source venv/bin/activate
- os: ubuntu-24.04
python: 3.13.9
numpy: 2.1.0
activate_command: source venv/bin/activate
- os: windows-2025
python: 3.11
numpy: 1.26.4
activate_command: .\venv\Scripts\activate
- os: windows-2025
python: 3.12
numpy: 1.26.4
activate_command: .\venv\Scripts\activate
- os: windows-2025
python: 3.13.9
numpy: 2.1.0
activate_command: .\venv\Scripts\activate
uses: ./.github/workflows/_before-pip.yaml
with:
Expand All @@ -44,13 +61,30 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-24.04, windows-2025]
numpy: [1.26.4]
python: [3.11, 3.12, 3.13.9]
include:
- os: ubuntu-24.04
python: 3.11
numpy: 1.26.4
activate_command: source venv/bin/activate
- os: ubuntu-24.04
python: 3.12
numpy: 1.26.4
activate_command: source venv/bin/activate
- os: ubuntu-24.04
python: 3.13.9
numpy: 2.1.0
activate_command: source venv/bin/activate
- os: windows-2025
python: 3.11
numpy: 1.26.4
activate_command: .\venv\Scripts\activate
- os: windows-2025
python: 3.12
numpy: 1.26.4
activate_command: .\venv\Scripts\activate
- os: windows-2025
python: 3.13.9
numpy: 2.1.0
activate_command: .\venv\Scripts\activate
uses: ./.github/workflows/_test-pip.yaml
with:
Expand All @@ -72,8 +106,13 @@ jobs:
strategy:
fail-fast: true
matrix:
numpy: [1.26.4]
python: [3.11, 3.12, 3.13.9]
include:
- python: 3.11
numpy: 1.26.4
- python: 3.12
numpy: 1.26.4
- python: 3.13.9
numpy: 2.1.0
uses: ./.github/workflows/_lint-pip.yaml
with:
os: ubuntu-24.04
Expand Down
55 changes: 47 additions & 8 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,34 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-24.04, windows-2025]
numpy: [1.26.4]
# Patch version must be specified to avoid any cache confusion, since
# the cache key depends on the full Python version. If left unspecified,
# different patch versions could be allocated between jobs, and any
# such difference would lead to a cache not found error.
python: [3.11, 3.12, 3.13.9]
include:
- os: ubuntu-24.04
python: 3.11
numpy: 1.26.4
activate_command: source venv/bin/activate
- os: ubuntu-24.04
python: 3.12
numpy: 1.26.4
activate_command: source venv/bin/activate
- os: ubuntu-24.04
python: 3.13.9
numpy: 2.1.0
activate_command: source venv/bin/activate
- os: windows-2025
python: 3.11
numpy: 1.26.4
activate_command: .\venv\Scripts\activate
- os: windows-2025
python: 3.12
numpy: 1.26.4
activate_command: .\venv\Scripts\activate
- os: windows-2025
python: 3.13.9
numpy: 2.1.0
activate_command: .\venv\Scripts\activate
uses: ./.github/workflows/_before-pip.yaml
with:
Expand All @@ -44,13 +61,30 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, windows-2025]
numpy: [1.26.4]
python: [3.11, 3.12, 3.13.9]
include:
- os: ubuntu-24.04
python: 3.11
numpy: 1.26.4
activate_command: source venv/bin/activate
- os: ubuntu-24.04
python: 3.12
numpy: 1.26.4
activate_command: source venv/bin/activate
- os: ubuntu-24.04
python: 3.13.9
numpy: 2.1.0
activate_command: source venv/bin/activate
- os: windows-2025
python: 3.11
numpy: 1.26.4
activate_command: .\venv\Scripts\activate
- os: windows-2025
python: 3.12
numpy: 1.26.4
activate_command: .\venv\Scripts\activate
- os: windows-2025
python: 3.13.9
numpy: 2.1.0
activate_command: .\venv\Scripts\activate
uses: ./.github/workflows/_test-pip.yaml
with:
Expand All @@ -72,8 +106,13 @@ jobs:
strategy:
fail-fast: true
matrix:
numpy: [1.26.4]
python: [3.11, 3.12, 3.13.9]
include:
- python: 3.11
numpy: 1.26.4
- python: 3.12
numpy: 1.26.4
- python: 3.13.9
numpy: 2.1.0
uses: ./.github/workflows/_lint-pip.yaml
with:
os: ubuntu-24.04
Expand Down
2 changes: 1 addition & 1 deletion openfisca_core/commons/formulas.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def apply_thresholds(
array([10, 10, 15, 15, 20])

"""
condlist: list[t.Array[numpy.bool_] | bool]
condlist: list[t.Array[t.BoolDType] | bool]
condlist = [input <= threshold for threshold in thresholds]

if len(condlist) == len(choices) - 1:
Expand Down
11 changes: 9 additions & 2 deletions openfisca_core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@

import numpy
import pendulum

# NumPy 1.x/2.x compatibility
# In NumPy 2.0, numpy.bool_ was removed and replaced with numpy.bool
Comment on lines +15 to +16
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to support old numpy? Could we move forward and say 2.0 needed?

try:
from numpy import bool as BoolDType
except ImportError:
from numpy import bool_ as BoolDType # type: ignore[attr-defined]

from numpy import (
bool_ as BoolDType,
bytes_ as BytesDType,
datetime64 as DateDType,
float32 as FloatDType,
Expand Down Expand Up @@ -70,7 +77,7 @@
ArrayLike: TypeAlias = Sequence[_L]

#: Type for bool arrays.
DTypeBool: TypeAlias = numpy.bool_
DTypeBool: TypeAlias = BoolDType

#: Type for int arrays.
DTypeInt: TypeAlias = numpy.int32
Expand Down
4 changes: 2 additions & 2 deletions openfisca_core/variables/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import numpy

from openfisca_core import indexed_enums
from openfisca_core import indexed_enums, types
from openfisca_core.indexed_enums import Enum

VALUE_TYPES = {
bool: {
"dtype": numpy.bool_,
"dtype": types.BoolDType,
"default": False,
"json_type": "boolean",
"formatted_value_type": "Boolean",
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"StrEnum >=0.4.8, <0.5.0", # 3.11.x backport
"dpath >=2.2.0, <3.0",
"numexpr >=2.10.1, <3.0",
"numpy >=1.24.2, <2.0",
"numpy >=1.24.2, <2.0; python_version < '3.13'",
"numpy >=2.1.0, <3.0; python_version >= '3.13'",
"pendulum >=3.0.0, <4.0.0",
"psutil >=5.9.4, <6.0",
"pytest >=8.3.3, <9.0",
Expand Down
Loading