refactor: move to popsummary format to store probs#850
Conversation
There was a problem hiding this comment.
Code Review
This pull request integrates the popsummary library to manage population results and grid rates, replacing custom domain reading/writing logic and raw HDF5 operations in marginals.py. It also adds support for numpy types when reading HDF5 attributes in utils.py. The review feedback recommends converting filepath to a string for compatibility, explicitly closing PopulationResult objects to prevent file locking, using a more robust list comprehension for constructing hyperparameters, ensuring domains keys are cast to strings, and correcting a type annotation for pos_and_rates.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| ) | ||
|
|
||
| for i in range(N_components): | ||
| comp_i_group = probs_group.create_group(f"component_{i}") | ||
| for idx, param in enumerate(parameters): | ||
| write_to_hdf5(comp_i_group, param, np.array(batched_results[i][idx])) | ||
| write_to_hdf5( | ||
| filepath, | ||
| dataset_path="/posterior/hyperparameter_samples", | ||
| attrs={"constants": constants, "variables_index": variables_index}, | ||
| ) |
There was a problem hiding this comment.
Explicitly closing the PopulationResult object ensures that all writes are flushed to disk and the file handle is released before write_to_hdf5 attempts to open the same file. This prevents potential file locking issues or write conflicts.
| ) | |
| for i in range(N_components): | |
| comp_i_group = probs_group.create_group(f"component_{i}") | |
| for idx, param in enumerate(parameters): | |
| write_to_hdf5(comp_i_group, param, np.array(batched_results[i][idx])) | |
| write_to_hdf5( | |
| filepath, | |
| dataset_path="/posterior/hyperparameter_samples", | |
| attrs={"constants": constants, "variables_index": variables_index}, | |
| ) | |
| ) | |
| result.close() | |
| write_to_hdf5( | |
| filepath, | |
| dataset_path="/posterior/hyperparameter_samples", | |
| attrs={"constants": constants, "variables_index": variables_index}, | |
| ) |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
No description provided.