-
Notifications
You must be signed in to change notification settings - Fork 0
Split raw_results.columns into columns_with_internal_p_ids / columns_with_original_p_ids #131
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5eb5fcb
Move p_id reverse-translation to new node raw_results.columns_with_re…
MImmesberger aa73a13
Rename to symmetric pair: columns_with_internal_p_ids / columns_with_…
MImmesberger 3113a66
Replace #130 regression test with one mirroring GETTSIM's test_jittable
MImmesberger 25b11f5
Prune low-value tests in test_raw_results.py
MImmesberger 034e6d5
Drop downstream reference from regression-test docstring
MImmesberger 987f29b
Replace one-off regression test with jittability test over all mettsi…
MImmesberger 85f0036
Re-add is_interface_function tests; shorten CHANGES entry
MImmesberger 04c63c7
Remove unit test of columns_with_original_p_ids; behavior is covered …
MImmesberger 678bc1c
Exclude jittability test from codecov
MImmesberger e414911
Docstrings.
MImmesberger bdd4912
Merge branch 'fix-130-remapped-ids-node' of github.com:ttsim-dev/ttsi…
MImmesberger 97b6a09
Merge branch 'main' into fix-130-remapped-ids-node
hmgaudecker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,91 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import datetime | ||
| import functools | ||
| import inspect | ||
| from typing import TYPE_CHECKING, Literal | ||
|
|
||
| import dags.tree as dt | ||
| import pytest | ||
| from dags import get_free_arguments | ||
| from mettsim import middle_earth | ||
|
|
||
| from ttsim import ( | ||
| MainTarget, | ||
| OrigPolicyObjects, | ||
| SpecializedEnvironment, | ||
| TTTargets, | ||
| main, | ||
| ) | ||
| from ttsim.tt import ColumnFunction | ||
|
|
||
| if TYPE_CHECKING: | ||
| from ttsim.typing import SpecEnvWithPartialledParamsAndScalars | ||
|
|
||
|
|
||
| def get_orig_mettsim_column_functions() -> list[tuple[tuple[str, ...], ColumnFunction]]: | ||
| orig = main( | ||
| main_target=MainTarget.orig_policy_objects.column_objects_and_param_functions, | ||
| orig_policy_objects=OrigPolicyObjects.root(middle_earth.ROOT_PATH), | ||
| ) | ||
| return [(tp, cf) for tp, cf in orig.items() if isinstance(cf, ColumnFunction)] | ||
|
|
||
|
|
||
| @functools.lru_cache(maxsize=100) | ||
| def cached_specialized_environment( | ||
| policy_date: datetime.date, | ||
| backend: Literal["numpy", "jax"], | ||
| ) -> SpecEnvWithPartialledParamsAndScalars: | ||
| return main( | ||
| main_target=( | ||
| "specialized_environment_for_plotting_and_templates", | ||
| "with_partialled_params_and_scalars", | ||
| ), | ||
| policy_date=policy_date, | ||
| orig_policy_objects=OrigPolicyObjects.root(middle_earth.ROOT_PATH), | ||
| backend=backend, | ||
| include_fail_nodes=False, | ||
| include_warn_nodes=False, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.skipif_numpy | ||
| @pytest.mark.parametrize( | ||
| ("tree_path", "fun"), | ||
| get_orig_mettsim_column_functions(), | ||
| ids=[str(x[0]) for x in get_orig_mettsim_column_functions()], | ||
| ) | ||
| def test_jittable(tree_path, fun, backend, xnp): | ||
| policy_date = min(fun.end_date, datetime.date.today()) # noqa: DTZ011 | ||
| qname = dt.qname_from_tree_path((*tree_path[:-2], fun.leaf_name)) | ||
| env = { | ||
| qname: cached_specialized_environment(policy_date=policy_date, backend=backend)[ | ||
| qname | ||
| ] | ||
| } | ||
|
|
||
| processed_data = {} | ||
| for arg_name in get_free_arguments(env[qname]): | ||
| arg = inspect.signature(env[qname]).parameters[arg_name] | ||
| if "FloatColumn" in arg.annotation: | ||
| processed_data[arg_name] = xnp.zeros(1, dtype=float) | ||
| elif "IntColumn" in arg.annotation: | ||
| processed_data[arg_name] = xnp.zeros(1, dtype=int) | ||
| elif "BoolColumn" in arg.annotation: | ||
| processed_data[arg_name] = xnp.zeros(1, dtype=bool) | ||
| else: | ||
| raise ValueError(f"Unknown column type: {arg.annotation}") | ||
|
|
||
| if not fun.fail_msg_if_included: | ||
| main( | ||
| main_target=("raw_results", "columns_with_internal_p_ids"), | ||
| policy_date=policy_date, | ||
| specialized_environment=SpecializedEnvironment.with_partialled_params_and_scalars( | ||
| env | ||
| ), | ||
| processed_data=processed_data, | ||
| tt_targets=TTTargets.qname([qname]), | ||
| backend=backend, | ||
| include_fail_nodes=False, | ||
| include_warn_nodes=False, | ||
| ) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.