Skip to content

Add x0 functionality to mcmc sampling. - #217

Merged
arm61 merged 5 commits into
mainfrom
issue-214
Jul 9, 2026
Merged

Add x0 functionality to mcmc sampling.#217
arm61 merged 5 commits into
mainfrom
issue-214

Conversation

@arm61

@arm61 arm61 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

@Lorentyfle would you be able to have a look at this PR?

@arm61

arm61 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

Merging this would close #214

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
2158 2049 95% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
kinisi/fitting.py 96% 🟢
kinisi/tests/test_fitting.py 100% 🟢
TOTAL 98% 🟢

updated for commit: 36a005d by action🐍

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends kinisi.fitting.FittingBase.mcmc to accept an optional x0 initial position for MCMC sampling, and adds tests to validate correct behavior and unit checking.

Changes:

  • Add an optional x0 argument to FittingBase.mcmc with basic unit validation.
  • Add unit tests covering x0 usage and incorrect-unit rejection.
  • Introduce pytest usage in test_fitting.py for exception assertions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
kinisi/fitting.py Adds x0 support to MCMC initialization and updates docstring.
kinisi/tests/test_fitting.py Adds tests for x0 initialization and wrong-unit handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread kinisi/fitting.py
Comment thread kinisi/fitting.py Outdated
arm61 and others added 3 commits July 9, 2026 10:58
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Lorentyfle

Copy link
Copy Markdown
Contributor

To review this pull request functionality, as github verified all the tests I decided to check if data are well reproduced using my own data and comparing it to result given by the old version of Kinisi:

Code used for testing this PR:

from scipy.stats import lognorm
###############################################################################
# BOUNDS
###############################################################################

x0 = (
    # activation_energy_low
        1.78 * sc.Unit("eV")
    ,
      # activation_energy_high
        1.05 * sc.Unit("eV")
    ,
    # preexponential_factor = D(T0)
        1.75e-5 * td_D.data.unit
    ,
      # Tc
        1380 * sc.Unit("K")
    )
priors = (
    # activation_energy_low
        lognorm(s=1.78,scale=0.2)
    ,
      # activation_energy_high
        lognorm(s=1.05,scale=0.2)
    ,
    # preexponential_factor = D(T0)
        lognorm(s=0.5,scale=1.75e-5)
    ,
      # Tc
        lognorm(s=1380,scale=100)
    )

###############################################################################
# MCMC
###############################################################################

print("===> Launching piece-wise arrhenius")

tdsA = PiecewiseArrhenius(
    td_D,
    priors=priors
)
tdsA.mcmc(x0=x0)
print("===> MCMC completed")

Old Kinisi results:

image image

Current PR results:

image image

Conclusion

Because the results are identical in both versions of Kinisi, the addition of the functionality is correct and fully functional.

@arm61
arm61 merged commit c683df5 into main Jul 9, 2026
8 checks passed
@arm61
arm61 deleted the issue-214 branch July 13, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants