Skip to content
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

Param hotfix #194

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions python/ngen_cal/src/ngen/cal/ngen.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,30 @@ def _params_as_df(params: Mapping[str, Parameters], name: str = None):
df['model'] = k
df.rename(columns={'name':'param'}, inplace=True)
dfs.append(df)
return pd.concat(dfs)
df = pd.concat(dfs)
# Copy the parameter column and use it as the index
# The param -> model relation has to be maintained for writing back
# to specific model components later
df['p'] = df['param']
return df.set_index('p')
else:
p = params.get(name, [])
df = pd.DataFrame([s.__dict__ for s in p])
df['model'] = name
df.rename(columns={'name':'param'}, inplace=True)
return df
if p:
df['p'] = df['param']
return df.set_index('p')
else:
return df

def _map_params_to_realization(params: Mapping[str, Parameters], realization: Realization):
# don't even think about calibration multiple formulations at once just yet..
# Since params are mapped by model name, we can track the model/param relationship
# in the dataframe to reconstruct each models parameters indepndently
# with a unique parameter index build in _params_as_df, this supports multi-model
# parameters with a key distinction --
# WARNING parameters with the _exact_ same name between two models will be exposed
# as two parameters in the parameter space, but will always share the same value
module = realization.formulations[0].params

if isinstance(module, MultiBMI):
Expand Down
Loading