Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

alexhroom
Copy link
Collaborator

@alexhroom alexhroom commented Apr 29, 2025

Currently, the chain plots crash if maxpoints is larger than the length of the chain. This is because we use a skip variable:
skip = floor(nsimulations / maxpoints)
which gives us spacing so that the sampled points in the plot are evenly distributed across the chain. However, if nsimulations < maxpoints, then skip will be 0, which causes a crash when we try to use it for a range skip.

We fix this by replacing the above line with
skip = max(floor(nsimulations / maxpoints), 1)
so that skip is set to 1 (i.e. the entire chain is plotted) when nsimulations < maxpoints.

To reproduce:

import RATapi as RAT

project, _ = RAT.examples.DSPC_standard_layers()
# broken for any nSamples < 15000 (the default value of maxpoints)
controls = RAT.Controls(procedure="dream", nSamples=1000)

_, results = RAT.run(project, controls)
RAT.utils.plotting.plot_chain(results)
# crash

@alexhroom alexhroom requested a review from DrPaulSharp April 29, 2025 10:04
@alexhroom alexhroom merged commit 513ee70 into main Apr 29, 2025
7 checks passed
@alexhroom alexhroom deleted the fix-chain-plots branch April 29, 2025 10:51
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.

2 participants