Skip to content

changed id of model_builder to property, added type hinting #110

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
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
7 changes: 4 additions & 3 deletions pymc_experimental/model_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def load(cls, fname):
idata.fit_data.to_dataframe(),
)
self.idata = idata
if self.id() != idata.attrs["id"]:
if self.id != idata.attrs["id"]:
raise ValueError(
f"The file '{fname}' does not contain an inference data of the same model or configuration as '{self._model_type}'"
)
Expand Down Expand Up @@ -234,7 +234,7 @@ def fit(self, data: Dict[str, Union[np.ndarray, pd.DataFrame, pd.Series]] = None
self.idata.extend(pm.sample_prior_predictive())
self.idata.extend(pm.sample_posterior_predictive(self.idata))

self.idata.attrs["id"] = self.id()
self.idata.attrs["id"] = self.id
self.idata.attrs["model_type"] = self._model_type
self.idata.attrs["version"] = self.version
self.idata.attrs["sample_config_keys"] = tuple(self.sample_config.keys())
Expand Down Expand Up @@ -344,7 +344,8 @@ def _extract_samples(post_pred: az.data.inference_data.InferenceData) -> Dict[st

return post_pred_dict

def id(self):
@property
def id(self) -> str:
"""
It creates a hash value to match the model version using last 16 characters of hash encoding.

Expand Down