generated from NOAA-OWP/owp-open-source-project-template
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for parameters with same name
- Loading branch information
1 parent
8124cd1
commit f5c7f72
Showing
1 changed file
with
26 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from __future__ import annotations | ||
|
||
from ngen.cal.ngen import _params_as_df | ||
import pandas as pd | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from typing import Mapping | ||
from ngen.cal.parameter import Parameter | ||
|
||
def test_multi_params(multi_model_shared_params: Mapping[str, list[Parameter]]): | ||
# This is essentially the path the params go through from | ||
# creation in model.py to update in search.py | ||
params = _params_as_df(multi_model_shared_params) | ||
params = pd.DataFrame(params).rename(columns={'init':'0'}) | ||
# create new iteration from old | ||
params['1'] = params['0'] | ||
#update the parameters by index | ||
params.loc[0, '1'] = 0.5 | ||
pa = params[ params['model'] == 'A' ] | ||
pb = params[ params['model'] == 'B' ] | ||
|
||
assert pa.drop('model', axis=1).equals( pb.drop('model', axis=1) ) | ||
|
||
# TODO test/document case where params have same name but different min/max/init values |