Skip to content

Commit

Permalink
doc(commons): add py.typed
Browse files Browse the repository at this point in the history
  • Loading branch information
bonjourmauko committed Sep 17, 2024
1 parent 32b61f2 commit d835de6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions openfisca_core/commons/formulas.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from collections.abc import Mapping
from typing import Union

from openfisca_core.types import Array, ArrayLike

import numpy

from openfisca_core import types as t


def apply_thresholds(
input: Array[numpy.float_],
thresholds: ArrayLike[float],
choices: ArrayLike[float],
) -> Array[numpy.float_]:
input: t.Array[numpy.float_],
thresholds: t.ArrayLike[float],
choices: t.ArrayLike[float],
) -> t.Array[numpy.float_]:
"""Makes a choice based on an input and thresholds.
From a list of ``choices``, this function selects one of these values
Expand Down Expand Up @@ -39,7 +39,7 @@ def apply_thresholds(
"""

condlist: list[Union[Array[numpy.bool_], bool]]
condlist: list[Union[t.Array[numpy.bool_], bool]]
condlist = [input <= threshold for threshold in thresholds]

if len(condlist) == len(choices) - 1:
Expand All @@ -58,9 +58,9 @@ def apply_thresholds(


def concat(
this: Union[Array[numpy.str_], ArrayLike[str]],
that: Union[Array[numpy.str_], ArrayLike[str]],
) -> Array[numpy.str_]:
this: Union[t.Array[numpy.str_], t.ArrayLike[str]],
that: Union[t.Array[numpy.str_], t.ArrayLike[str]],
) -> t.Array[numpy.str_]:
"""Concatenates the values of two arrays.
Args:
Expand Down Expand Up @@ -89,9 +89,9 @@ def concat(


def switch(
conditions: Array[numpy.float_],
conditions: t.Array[numpy.float_],
value_by_condition: Mapping[float, float],
) -> Array[numpy.float_]:
) -> t.Array[numpy.float_]:
"""Mimicks a switch statement.
Given an array of conditions, returns an array of the same size,
Expand Down
6 changes: 3 additions & 3 deletions openfisca_core/commons/misc.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Optional, TypeVar

from openfisca_core.types import Array

import numpy

from openfisca_core import types as t

T = TypeVar("T")


Expand Down Expand Up @@ -45,7 +45,7 @@ def empty_clone(original: T) -> T:
return new


def stringify_array(array: Optional[Array[numpy.generic]]) -> str:
def stringify_array(array: Optional[t.Array[numpy.generic]]) -> str:
"""Generates a clean string representation of a numpy array.
Args:
Expand Down
Empty file added openfisca_core/commons/py.typed
Empty file.

0 comments on commit d835de6

Please sign in to comment.