Skip to content

vp-comparefit issue, due to arclength errors - #1681

Merged
Zaharid merged 4 commits into
masterfrom
issue_w_vp_comparefits
Mar 8, 2023
Merged

vp-comparefit issue, due to arclength errors#1681
Zaharid merged 4 commits into
masterfrom
issue_w_vp_comparefits

Conversation

@comane

@comane comane commented Feb 27, 2023

Copy link
Copy Markdown
Member

@Zaharid , @enocera Issue with vp-comparefit due to arclength function.
my guess is that the problem arises from these lines of the code within validphys.arclength.plot_arc_lengths:
yvalues = arclengths.stats.central_value()
ylower, yupper = arclengths.stats.errorbar68()
ylower = yvalues - ylower
yupper = yupper - yvalues
Some of the replicas might be shorter than the central replica. The problem is thus probably fixed by taking the absolute value of the difference.

Another possible issue might be in validphys.arclength.arc_lengths, namely, in
res += integrate.simps(1 + np.square(fdiff), ixgrid[1][1:])
It looks like a square root is missing here:
res += integrate.simps(np.sqrt(1 + np.square(fdiff)), ixgrid[1][1:])

@Zaharid

Zaharid commented Feb 27, 2023

Copy link
Copy Markdown
Contributor

@comane thanks for this!

@Zaharid , @enocera Issue with vp-comparefit due to arclength function. my guess is that the problem arises from these lines of the code within validphys.arclength.plot_arc_lengths: yvalues = arclengths.stats.central_value() ylower, yupper = arclengths.stats.errorbar68() ylower = yvalues - ylower yupper = yupper - yvalues Some of the replicas might be shorter than the central replica. The problem is thus probably fixed by taking the absolute value of the difference.

This is rather the result of mixing means with quantiles. Incidentally I believe it was fine before and we changed it because people complained, but then we got this bug.. I don't think taking the cleanest solution for one we would like the length of the error bar to be yupper-ylower in any case. I think we should just use the median.

Another possible issue might be in validphys.arclength.arc_lengths, namely, in res += integrate.simps(1 + np.square(fdiff), ixgrid[1][1:]) It looks like a square root is missing here: res += integrate.simps(np.sqrt(1 + np.square(fdiff)), ixgrid[1][1:])

Uh. @scarlehoff @RoyStegeman, @enocera could you have a look at this please?

@scarlehoff

scarlehoff commented Feb 27, 2023

Copy link
Copy Markdown
Member

This is not branching from master, is it?

It looks like a square root is missing here:
res += integrate.simps(np.sqrt(1 + np.square(fdiff)), ixgrid[1][1:])

Looking at the blame, the square was removed six years ago. Was it intentional?
In any case, I would not change this. The fact that we are not computing an actual arclength is less relevant than keeping the quantity unchanged (as we normally only care about its value wrt other fits/replicas).

@RoyStegeman

Copy link
Copy Markdown
Member

Looking at the blame, the square was removed six years ago. Was it intentional?

Yes this is a bit odd... I'd still be in favor of doing the correct thing now though, even if we're mainly just comparing relative lengths anyway. We hardly compare this between different reports, especially older ones, so I don't see huge issues arise if we fix it

@scarlehoff

Copy link
Copy Markdown
Member

(Let me tag @scarrazza as well maybe he has some memory of this)

@scarlehoff scarlehoff added the run-fit-bot Starts fit bot from a PR. label Mar 1, 2023

@scarlehoff scarlehoff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please rebase on the current master so that you get the tests running for python 3.9/3.10.

Also, you will need to update also the regression tests since you changed the form of the arclength.

wrt the np.sqrt, as @RoyStegeman says it doesn't really matter since we never use the actual value but I would prefer if some of the people who was around when that change was made could comment just in case it was actually intentional for some obscure reason.

Comment thread validphys2/src/validphys/arclength.py Outdated
Comment on lines +124 to +125
ylower = np.abs(yvalues - ylower)
yupper = np.abs(yupper - yvalues)

@scarlehoff scarlehoff Mar 1, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
ylower = np.abs(yvalues - ylower)
yupper = np.abs(yupper - yvalues)
ylower = np.maximum(yvalues - ylower, 0)
yupper = np.maximum(yupper - yvalues, 0)

I think this is more consistent with what we do in other cases of negative numbers that we don't like (it should not matte much though, it's just a question of taste I guess)

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.

As said above, I think the line should be always of length yupper - ylower. We could even remove the point in the middle and be done with it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That would also work for me.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As said above, I think the line should be always of length yupper - ylower

This is what the modification already does I think.
@Zaharid, @scarlehoff I pushed the rebased version, but it's not running the tests.

@scarlehoff scarlehoff Mar 2, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it was just that github needs a few minutes to reset (and the test failed because of the regression test since the AL has changed).

This is what the modification already does I think.

Maybe I misunderstood @Zaharid but I think what he would like is just to plot ylower-----yupper instead of yvalues +/- (yupper, ywloer) (and now that I write it down I think I agree, we would like to see the spread, we are already removing outliers at postfit so they are not going (should not) to break the plot)

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.

Except that yvalues should be something like (yupper - ylower)/2. Otherwise we are back to the original problem.

@github-actions

github-actions Bot commented Mar 1, 2023

Copy link
Copy Markdown

Greetings from your nice fit 🤖 !
I have good news for you, I just finished my tasks:

Check the report carefully, and please buy me a ☕ , or better, a GPU 😉!

Edit by @scarlehoff

arclenghts plots for this report and another similar one
https://vp.nnpdf.science/rHyJIv7ZQLiTvTWjY0Ntgg==/#pdf-arc-lengths
https://vp.nnpdf.science/AdxUWwM8SBCUWe0FPTcEDA==/#pdf-arc-lengths

@comane
comane force-pushed the issue_w_vp_comparefits branch from d164a4c to 8cd821d Compare March 1, 2023 19:07
Comment on lines -137 to +138
fmt=".",
fmt='',
linestyle = '',

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok I am still not completely sure on whether I understood. However, the following modification should do it.

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.

@scarlehoff

Copy link
Copy Markdown
Member

FAILED tests/test_plots.py::test_plot_xq2

@Zaharid we should just remove the plot tests or change the thresholds because they are a nightmare.

@Zaharid

Zaharid commented Mar 3, 2023

Copy link
Copy Markdown
Contributor

The plot tests have been fairly stable for years, and seem to have gotten unstable only lately (due to I guess a bigger update in mpl). Would suggest just dealing with it for now by updating the plots. Let's revisit the issue if this keep happening.

@scarlehoff scarlehoff added run-fit-bot Starts fit bot from a PR. and removed run-fit-bot Starts fit bot from a PR. labels Mar 7, 2023
@Zaharid

Zaharid commented Mar 7, 2023

Copy link
Copy Markdown
Contributor

Looks okay to me the way it is now.

@github-actions

github-actions Bot commented Mar 7, 2023

Copy link
Copy Markdown

Greetings from your nice fit 🤖 !
I have good news for you, I just finished my tasks:

Check the report carefully, and please buy me a ☕ , or better, a GPU 😉!

@scarlehoff

Copy link
Copy Markdown
Member

@scarlehoff scarlehoff removed the run-fit-bot Starts fit bot from a PR. label Mar 8, 2023
@Zaharid
Zaharid merged commit 1c2feb8 into master Mar 8, 2023
@Zaharid
Zaharid deleted the issue_w_vp_comparefits branch March 8, 2023 15:36
@Zaharid

Zaharid commented Mar 8, 2023

Copy link
Copy Markdown
Contributor

@scarlehoff could you see what the current test failure on master is?

@scarlehoff

Copy link
Copy Markdown
Member

Ah, the arclengths changed so the regression of the fit will also see a change of course. And that test is also not run in mac, I forgot about it.

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.

4 participants