-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(experimental): add docs (#1275)
- Loading branch information
Showing
14 changed files
with
70 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,9 @@ | ||
# Transitional imports to ensure non-breaking changes. | ||
# Could be deprecated in the next major release. | ||
# | ||
# How imports are being used today: | ||
# | ||
# >>> from openfisca_core.module import symbol | ||
# | ||
# The previous example provokes cyclic dependency problems | ||
# that prevent us from modularizing the different components | ||
# of the library so to make them easier to test and to maintain. | ||
# | ||
# How could them be used after the next major release: | ||
# | ||
# >>> from openfisca_core import module | ||
# >>> module.symbol() | ||
# | ||
# And for classes: | ||
# | ||
# >>> from openfisca_core.module import Symbol | ||
# >>> Symbol() | ||
# | ||
# See: https://www.python.org/dev/peps/pep-0008/#imports | ||
"""Experimental features of OpenFisca-Core.""" | ||
|
||
from .memory_config import MemoryConfig # noqa: F401 | ||
from ._errors import MemoryConfigWarning | ||
from ._memory_config import MemoryConfig | ||
|
||
__all__ = [ | ||
"MemoryConfig", | ||
"MemoryConfigWarning", | ||
] |
3 changes: 3 additions & 0 deletions
3
openfisca_core/warnings/memory_warning.py → openfisca_core/experimental/_errors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
class MemoryConfigWarning(UserWarning): | ||
"""Custom warning for MemoryConfig.""" | ||
|
||
|
||
__all__ = ["MemoryConfigWarning"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from __future__ import annotations | ||
|
||
from collections.abc import Iterable | ||
|
||
import warnings | ||
|
||
from ._errors import MemoryConfigWarning | ||
|
||
|
||
class MemoryConfig: | ||
"""Experimental memory configuration.""" | ||
|
||
#: Maximum memory occupation allowed. | ||
max_memory_occupation: float | ||
|
||
#: Priority variables. | ||
priority_variables: frozenset[str] | ||
|
||
#: Variables to drop. | ||
variables_to_drop: frozenset[str] | ||
|
||
def __init__( | ||
self, | ||
max_memory_occupation: str | float, | ||
priority_variables: Iterable[str] = frozenset(), | ||
variables_to_drop: Iterable[str] = frozenset(), | ||
) -> None: | ||
message = [ | ||
"Memory configuration is a feature that is still currently under " | ||
"experimentation. You are very welcome to use it and send us " | ||
"precious feedback, but keep in mind that the way it is used might " | ||
"change without any major version bump.", | ||
] | ||
warnings.warn(" ".join(message), MemoryConfigWarning, stacklevel=2) | ||
|
||
self.max_memory_occupation = float(max_memory_occupation) | ||
if self.max_memory_occupation > 1: | ||
msg = "max_memory_occupation must be <= 1" | ||
raise ValueError(msg) | ||
self.max_memory_occupation_pc = self.max_memory_occupation * 100 | ||
self.priority_variables = frozenset(priority_variables) | ||
self.variables_to_drop = frozenset(variables_to_drop) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters