Skip to content

Releases: jyangch/bayspec

v0.3.12

Choose a tag to compare

@jyangch jyangch released this 13 Jul 14:52

Changed

  • Fixed zero-division edge cases in bayspec.infer.statistic for sparse short-exposure spectra.
  • Added explicit zero-denominator handling in numba statistic kernels:
    • Gstat now returns zero contribution for sigma=0 and zero residual, and +inf statistic for nonzero residual with zero uncertainty.
    • PPstat/cstat now handle degenerate profiled-background solutions where bb + dd == 0.
    • PGstat now handles degenerate profiled-background solutions where qq == 0 and zero Gaussian background uncertainty.
  • Synchronized the pure NumPy fallback Statistic.PPstat and Statistic.PGstat with StatisticNB, preventing nan results for zero-count / zero-model bins.
  • Non-degenerate statistic paths are unchanged.

Fixed

  • Prevented MultiNest likelihood evaluation from aborting with ZeroDivisionError when using pgstat on highly sparse spectra with zero background counts and zero background errors.
  • Prevented Statistic.PPstat and Statistic.PGstat fallback implementations from returning nan for the same degenerate zero-profile cases.

v0.3.11

Choose a tag to compare

@jyangch jyangch released this 06 May 06:48

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_property implementation to use single underscore (_cache_*) prefix for cache attributes per Python private-member conventions.
  • Documentation Enhancement — Expand docstrings for cached_property descriptor 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, MappingProxyType for dicts)
    • Add explicit exception chaining (raise ... from None/err)
    • Convert legacy format strings to f-strings
    • Enforce canonical Google-style docstring section titles (Example: not Typical usage:)
    • Inject __doc__ into dynamically-synthesized XSPEC/astromodels bridge classes

Python 3.8+ Compatibility

  • Add from __future__ import annotations to bayspec/util/corner.py to 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.toml with ruff linter configuration (py312 target, code quality rules UP/B/SIM/RUF enabled).

🐛 Bug Fixes

  • Mutable Default Fixes — Eliminate shared mutable default values in Response / Spectrum / BalrogResponse constructors; each instance now gets a fresh Par() object (fixes latent identity-based comparison bugs).
  • Exception Handling — Improve exception chaining clarity in model/data property getters; replace bare except: with except Exception: in emcee integration to allow proper KeyboardInterrupt propagation.
  • 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; ignore RUF001/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

Choose a tag to compare

@jyangch jyangch released this 20 Apr 12:28

add docstring

v0.3.8

Choose a tag to compare

@jyangch jyangch released this 08 Apr 15:08

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

Choose a tag to compare

@jyangch jyangch released this 07 Apr 05:21

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

Choose a tag to compare

@jyangch jyangch released this 25 Jan 09:37

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

Choose a tag to compare

@jyangch jyangch released this 01 Jan 12:40

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

Choose a tag to compare

@jyangch jyangch released this 20 Dec 14:58

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

Choose a tag to compare

@jyangch jyangch released this 23 Oct 12:51

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

Choose a tag to compare

@jyangch jyangch released this 15 Sep 08:24

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.