Skip to content

Commit

Permalink
docs: fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bonjourmauko committed Nov 19, 2024
1 parent 6fd3e52 commit bcf28a2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
6 changes: 3 additions & 3 deletions openfisca_core/populations/_core_population.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CorePopulation:
"""Base class to build populations from.
Args:
entity: The :class:`.CoreEntity` of the population.
entity: The :class:`~entities.CoreEntity` of the population.
*__args: Variable length argument list.
**__kwds: Arbitrary keyword arguments.
Expand All @@ -43,7 +43,7 @@ class CorePopulation:
#: A pseudo index for the members of the population.
ids: Sequence[str] = []

#: The :class:`.Simulation` for which the population is calculated.
#: The :class:`~simulations.Simulation` for which the population is calculated.
simulation: None | t.Simulation = None

#: The holders of the variables.
Expand All @@ -67,7 +67,7 @@ def __call__(
options: The options to use for the calculation.
Returns:
None: If there is no :class:`.Simulation`.
None: If there is no :class:`~simulations.Simulation`.
ndarray[generic]: The result of the calculation.
Raises:
Expand Down
4 changes: 3 additions & 1 deletion openfisca_core/populations/_errors.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from openfisca_core import types as t

from ._enums import Option


class IncompatibleOptionsError(ValueError):
"""Raised when two options are incompatible."""

def __init__(self, variable_name: t.VariableName) -> None:
add, divide = t.Option
add, divide = Option
msg = (
f"Options {add} and {divide} are incompatible (trying to compute "
f"variable {variable_name})."
Expand Down
3 changes: 2 additions & 1 deletion openfisca_core/reforms/reform.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def modify_parameters(self, modifier_function):
Call this function in `apply()` if the reform asks for legislation parameter modifications.
Args:
modifier_function: A function that takes a :obj:`.ParameterNode` and should return an object of the same type.
modifier_function: A function that takes a :obj:`~parameters.ParameterNode` and should return an object of
the same type.
"""
baseline_parameters = self.baseline.parameters
Expand Down
23 changes: 13 additions & 10 deletions openfisca_core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,6 @@ def __getitem__(self, __index: str | VarArray, /) -> ParameterNodeChild: ...
#: For example 2020.
PeriodInt = NewType("PeriodInt", int)

#: Type alias for a period-like object.
PeriodLike: TypeAlias = Union["Period", "PeriodStr", PeriodInt]


class _InstantStrMeta(type):
def __instancecheck__(self, arg: object) -> bool:
Expand Down Expand Up @@ -406,15 +403,15 @@ def offset(
) -> Period: ...


#: Type alias for a period-like object.
PeriodLike: TypeAlias = Union[Period, PeriodStr, PeriodInt]


# Populations

#: Type alias for a population's holders.
HolderByVariable: TypeAlias = MutableMapping["VariableName", Holder[_N]]

# TODO(Mauko Quiroga-Alvarado): I'm not sure if this type alias is correct.
# https://openfisca.org/doc/coding-the-legislation/50_entities.html
Members: TypeAlias = Iterable["SinglePopulation"]


class MemoryUsageByVariable(TypedDict, total=False):
by_variable: dict[VariableName, MemoryUsage]
Expand Down Expand Up @@ -448,6 +445,11 @@ def members_entity_id(self, /) -> StrArray: ...
def nb_persons(self, /, __role: None | Role = ...) -> int: ...


# TODO(Mauko Quiroga-Alvarado): I'm not sure if this type alias is correct.
# https://openfisca.org/doc/coding-the-legislation/50_entities.html
Members: TypeAlias = Iterable[SinglePopulation]


# Simulations


Expand Down Expand Up @@ -507,9 +509,6 @@ def instantiate_entities(self, /) -> dict[str, CorePopulation]: ...
#: A type representing a mapping of serialized traces.
SerializedNodeMap: TypeAlias = dict["NodeKey", "SerializedTraceMap"]

#: A stack of simple traces.
SimpleStack: TypeAlias = list["SimpleTraceMap"]

#: Key of a trace.
NodeKey = NewType("NodeKey", str)

Expand Down Expand Up @@ -587,6 +586,10 @@ def formula_time(self, /) -> Time: ...
def append_child(self, __node: TraceNode, /) -> None: ...


#: A stack of simple traces.
SimpleStack: TypeAlias = list[SimpleTraceMap]


# Variables

#: For example "salary".
Expand Down

0 comments on commit bcf28a2

Please sign in to comment.