Repository navigation
[graph] Do not abort scatter painting loop on non-positive log coordinates (fixes #23833) - #23834
muntasir-396 wants to merge 3 commits into
Conversation
…nates (fixes root-project#23833) - In TGraphPainter::PaintScatter and PaintScatter2D, replace 'else break;' with 'else continue;' in the log scale coordinate checks. - Ensures that non-positive coordinates (x, y, or z <= 0) on logarithmic axes are skipped individually without aborting the rendering of all subsequent valid positive markers. - Add regression unit tests in hist/hist/test/test_TScatter_Log.cxx.
ferdymercury
left a comment
There was a problem hiding this comment.
Does the same issue appear with TH2D drawn with COLZ with logz?
Thks
|
Thanks for the review! I checked The premature |
dpiparo
left a comment
There was a problem hiding this comment.
Thanks for this PR. Could you please address the comments so that we can start the integration process?
| ROOT_ADD_GTEST(test_th1d_tpad_buildlegend test_th1d_tpad_buildlegend.cxx LIBRARIES Hist Gpad) | ||
|
|
||
| # Test for https://github.com/root-project/root/issues/23833 | ||
| ROOT_ADD_GTEST(test_TScatter_Log test_TScatter_Log.cxx LIBRARIES Hist Gpad Graf Core) |
There was a problem hiding this comment.
can we call this test_tscatter and test_tscatter.cxx?
| TEST(TScatterLog, NonPositivePointsInLogScale) | ||
| { | ||
| gROOT->SetBatch(true); | ||
| auto c = new TCanvas("c_scatter_log", "c_scatter_log", 800, 600); |
| TEST(TScatter2DLog, NonPositivePointsInLogScale) | ||
| { | ||
| gROOT->SetBatch(true); | ||
| auto c = new TCanvas("c_scatter2d_log", "c_scatter2d_log", 800, 600); |
| double col[n] = {1.0, 2.0, 3.0, 4.0, 5.0}; | ||
| double size[n] = {2.0, 2.0, 2.0, 2.0, 2.0}; | ||
|
|
||
| auto scatter2d = new TScatter2D(n, x, y, z, col, size); |
|
@muntasir-396 , did you use AI for this contribution (see https://github.com/root-project/root/blob/master/CONTRIBUTING.md#ai-assisted-coding-disclosure)? |
|
Yes @dpiparo ,, I used an AI assistant to help draft the issue description, reproducer macro, and PR text, in compliance with the disclosure policy. I have reviewed and verified the underlying C++ fix in I have also addressed your review comments:
The updated commit has been pushed to the branch. Thank you for the guidance! |
|
thanks. Let's how the tests go. |
|
Updated in commit
Also note: the earlier |
Test Results0 tests 0 ✅ 0s ⏱️ Results for commit 0c65f14. |
There was a problem hiding this comment.
Provided solution incomplete. break in the code in some places was intentional while produced output will be corrupted anyway. In case of negative values on log axes ranges not correctly calculated.
Therefore one either fixes algorithm how ranges are defined (preferable way) or just print error message when negative value appears on the log scale. Only in the first case one then replace break by continue
Just to explain my comment - if color scale in TScatter2D is logarithmic then negative values made complete output incorrect. But seems to be X, Y and Z values handled correctly. So you only should keep replacement of break by continue for X,Y and Z coordinates.
Provided tests must be excluded - they test nothing. TScatter::GetHistogram() always return valid histogram pointer - disregard of problems during painting. Real graphics tests should be implemented in stressGraphics.cxx. There we missing test of TScatter2D for instance.
Summary
When plotting a
TScatterorTScatter2Don a pad with logarithmic scale enabled (gPad->SetLogx(),SetLogy(), orSetLogz()), encountering any non-positive coordinate (x <= 0, y <= 0, or z <= 0) causedTGraphPainter::PaintScatterandPaintScatter2Dto terminate the entire rendering loop viaelse break;.As a consequence, if an early point in the array happened to be non-positive, all subsequent valid positive points were omitted from the canvas.
Changes
TGraphPainter::PaintScatterandPaintScatter2D, replacedelse break;withelse continue;inlogx,logy, andlogzmarker loops.hist/hist/test/test_TScatter_Log.cxxtestingTScatterandTScatter2Dwith non-positive points under logarithmic scales.Fixes #23833.