Releases: jyangch/bayspec
Release list
v0.3.12
Changed
- Fixed zero-division edge cases in
bayspec.infer.statisticfor sparse short-exposure spectra. - Added explicit zero-denominator handling in numba statistic kernels:
Gstatnow returns zero contribution forsigma=0and zero residual, and+infstatistic for nonzero residual with zero uncertainty.PPstat/cstatnow handle degenerate profiled-background solutions wherebb + dd == 0.PGstatnow handles degenerate profiled-background solutions whereqq == 0and zero Gaussian background uncertainty.
- Synchronized the pure NumPy fallback
Statistic.PPstatandStatistic.PGstatwithStatisticNB, preventingnanresults for zero-count / zero-model bins. - Non-degenerate statistic paths are unchanged.
Fixed
- Prevented MultiNest likelihood evaluation from aborting with
ZeroDivisionErrorwhen usingpgstaton highly sparse spectra with zero background counts and zero background errors. - Prevented
Statistic.PPstatandStatistic.PGstatfallback implementations from returningnanfor the same degenerate zero-profile cases.
v0.3.11
bayspec 0.3.11 Changelog
Release Date: 2026-05-06
Previous Release: 0.3.10 (2026-04-27)
✨ Features
- Memoization Fingerprinting — Implement fingerprinting for memoization cache keys to enable robust caching of model evaluations across different parameter and data configurations. Improves inference performance for repeated evaluations.
🔧 Refactoring
Caching System
- Cache Attribute Convention — Update
cached_propertyimplementation to use single underscore (_cache_*) prefix for cache attributes per Python private-member conventions. - Documentation Enhancement — Expand docstrings for
cached_propertydescriptor explaining fingerprinting strategy, cache invalidation, and usage patterns.
Code Quality
- Format & Linting — Apply ruff formatting across the entire
bayspec/codebase (29 files):- Standardize quote styles, import ordering, and line wrapping
- Fix ambiguous Unicode punctuation (en/em dashes → ASCII)
- Resolve mutable default arguments (tuples for constants,
MappingProxyTypefor dicts) - Add explicit exception chaining (
raise ... from None/err) - Convert legacy format strings to f-strings
- Enforce canonical Google-style docstring section titles (
Example:notTypical usage:) - Inject
__doc__into dynamically-synthesized XSPEC/astromodels bridge classes
Python 3.8+ Compatibility
- Add
from __future__ import annotationstobayspec/util/corner.pyto support PEP 604 type hints (X | None) on Python 3.8–3.9.
📝 Documentation
- Updated Example Files — Re-run all Jupyter notebook examples (
quickstart,advancement,intermediate, etc.) with new fingerprinting logic; binary outputs and statistical results regenerated. - Configuration — Add
pyproject.tomlwith ruff linter configuration (py312target, code quality rules UP/B/SIM/RUF enabled).
🐛 Bug Fixes
- Mutable Default Fixes — Eliminate shared mutable default values in
Response/Spectrum/BalrogResponseconstructors; each instance now gets a freshPar()object (fixes latent identity-based comparison bugs). - Exception Handling — Improve exception chaining clarity in model/data property getters; replace bare
except:withexcept Exception:inemceeintegration to allow properKeyboardInterruptpropagation. - Resource Cleanup — Consolidate nested file-open context managers for proper resource cleanup on exceptions.
📦 Dependencies & Build
- Target Python:
py312(ruff minimum);python_requires='>=3.8'maintained (3.8/3.9 compat via__future__imports). - Ruff Linting: Enabled rules
E W F I UP B SIM RUF; ignoreRUF001/002/003(allowed-confusables whitelist for physics units).
Summary
0.3.11 is a maintenance + quality release focused on caching robustness, code standardization, and docstring/configuration completeness per the project's v1.2 docstring standard. No breaking API changes. All user-facing behavior is preserved; improvements are internal code quality and example reproducibility.
v0.3.10
v0.3.8
Update Log:
- Implemented the iminuit library within the MaxLikeFit class to facilitate robust Maximum Likelihood Estimation.
- Introduced a bootstrapping method for MaxLikeFit to generate extensive parameter samples, enabling the calculation of model uncertainties.
- Renamed the original Posterior class to SampleAnalyzer to better reflect its generalized functionality. Derived two specialized subclasses from SampleAnalyzer: Posterior and Bootstrap, dedicated to the analysis of posterior distributions and bootstrap samples, respectively.
v0.3.7
Update Log:
- Integration of Local Absorption Models: Implemented built-in local absorption models, including wabs, phabs, and tbabs.
- Performance Optimization via JIT Compilation: statistical operations within statistic.py and integration functions within model.py have been JIT-compiled to reduce execution overhead.
- Implementation of Memoization Decorators: Introduced a "memoized" decorator to cache property values and method results. This was applied to the cross-section interpolation within the absorption models, resulting in a significant increase in overall computational throughput.
v0.3.6
1, Removed the tinvloved model. Since the add and mul models now support time evolution, an independent tinv model is no longer necessary.
2, The Infer class now has two subclasses: BayesInfer and MaxLikeFit. The former handles Bayesian Inference (via multinest and emcee), while the latter handles the new Maximum Likelihood Estimation (via lmfit).
3, Added HTML information tables for outputs in Jupyter Notebooks.
v0.3.5
The configuration parameter vfv_peak was introduced to unify models such as cpl and ppl. Under this configuration, when vfv_peak is active (True), the peak energy Ep is treated as a free parameter. Furthermore, several models were renamed for consistency.
v0.3.1
1, A pivot_energy configuration parameter has been added to most local empirical models. The default value is set to 1, indicating that the normalization parameter corresponds to the model value at 1 keV. Note that to maintain consistency with its original functional definition, the pivot_energy for the Band function defaults to 100 keV.
2, Support for local multiplicative-type models has been introduced. Currently, the available model in this category is hecut (high-energy cutoff model).
3, When generating posterior-related plots (such as corner plot or spectral plot), the package now defaults to using the global best-fit parameters rather than the best-fit parameters within the 1sigma confidence interval. Additionally, a new parameter, at_par, has been introduced to allow manual selection of the parameter type. Supported options include: "best", "best_ci", "median", "mean".
v0.1.18
Version 0.1.17 allows the data to be treated as a “model” carrying free parameters, but this approach increases computational overhead. To address this, the current version introduces a cached property mechanism: the property is recalculated only when its dependent parameters change; otherwise, the cached value is used. This strategy effectively reduces the additional computational cost introduced in version 0.1.17.
v0.1.17
The spectrum and response classes in the data module can now be treated as "models", meaning they are capable of defining free parameters and participating in fitting procedures. This functionality gives rise to two application scenarios:
I: When the exposure times associated with spectrum and response require correction, a free multiplicative factor can be applied to adjust the exposure time during fitting.
II: In cases where the response depends on unknown right ascension (RA) and declination (Dec), these coordinates can be treated as free parameters in the fitting process, thereby enabling source localization.
These enhancements come at the cost of a modest increase in computational overhead, as variables derived from spectrum and response must now be dynamically updated in response to parameter changes.