Skip to content

WIP: Fix panel.margin with positive values (#180)#286

Open
ANAMASGARD wants to merge 5 commits intomasterfrom
fix-panel-margin-positive-values
Open

WIP: Fix panel.margin with positive values (#180)#286
ANAMASGARD wants to merge 5 commits intomasterfrom
fix-panel-margin-positive-values

Conversation

@ANAMASGARD
Copy link
Contributor

FIXES #180

Current Status

Tests failing (6/22) - this commit demonstrates the bug exists.

Problem Identified

pt.to.lines() returns constant 0.25 for all inputs instead of converting the actual value.

Current behavior:

  • grid::unit(2, "lines") returns 0.25 (expected: 2)
  • grid::unit(1, "cm") returns 0.25 (expected: ~2.86)
  • grid::unit(0, "lines") returns 0.25 (expected: 0)

Test Output

Screenshot From 2025-12-23 09-58-26

Tests demonstrate:
- pt.to.lines() returns 0.25 for all inputs (should vary)
- Zero values incorrectly return 0.25 instead of 0
- Positive values (2 lines, 1 cm) return 0.25 instead of correct conversion .
Issue #180 asked for test coverage of positive panel.margin values.
Added tests for lines, cm, and pt units. All tests pass - the
feature already works, just needed proper test coverage.

Fixes #180
@ANAMASGARD
Copy link
Contributor Author

What I Did

Added comprehensive test coverage for panel.margin with positive values (issue #180).

I added tests for:

  • Positive values in lines: grid::unit(2, "lines")
  • Positive values in cm: grid::unit(1, "cm")
  • Positive values in pt: grid::unit(12, "pt")
  • Comparison between zero and positive values

Test Results

  • All 22 tests pass
Screenshot From 2025-12-23 12-26-13

@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.71%. Comparing base (a5731da) to head (7ca1ff3).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #286   +/-   ##
=======================================
  Coverage   77.71%   77.71%           
=======================================
  Files         164      164           
  Lines        8769     8769           
  Branches      555      555           
=======================================
  Hits         6815     6815           
  Misses       1954     1954           
Flag Coverage Δ
javascript 95.46% <ø> (ø)
r 69.57% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ANAMASGARD
Copy link
Contributor Author

Sir @tdhock The R_coverage check is failing on an unrelated test
(test-compiler-ghpages.R:63) that expects 1 TSV file but finds 2.

This appears unrelated to panel.margin since my PR only adds test coverage
and doesn't modify any compilation or TSV generation code.

Sir can you please review the PR and guide me on what should I be doing next .

@tdhock
Copy link
Collaborator

tdhock commented Feb 27, 2026

can you please post screenshots?

Copy link
Collaborator

@tdhock tdhock left a comment

Choose a reason for hiding this comment

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

please add a renderer test

Comment on lines +3 to +22
lines_value <- grid::unit(2, "lines")
converted <- pt.to.lines(lines_value)
expect_true(is.numeric(converted))
expect_equal(converted, 2)
expect_gt(converted, 0)
})
test_that("pt.to.lines handles positive cm unit correctly", {
cm_value <- grid::unit(0.5, "cm")
converted <- pt.to.lines(cm_value)
expect_true(is.numeric(converted))
expect_gt(converted, 0)
expect_equal(as.numeric(cm_value), converted)
})
test_that("pt.to.lines handles positive pt unit correctly", {
pt_value <- grid::unit(12, "pt")
converted <- pt.to.lines(pt_value)
expect_true(is.numeric(converted))
expect_gt(converted, 0)
expect_false(identical(converted, as.numeric(pt_value)))
expected <- round(as.numeric(pt_value) * (0.25/5.5), digits = 2)
Copy link
Collaborator

Choose a reason for hiding this comment

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

please remove

@ANAMASGARD ANAMASGARD force-pushed the fix-panel-margin-positive-values branch from 7ba8e0d to 75b34d0 Compare March 9, 2026 07:42
@ANAMASGARD
Copy link
Contributor Author

Hi @tdhock, I've addressed all your feedback :-

Screenshots :-

  • Before (panel.margin = 0):
Screenshot From 2026-03-09 12-40-05
  • After (panel.margin = 2 lines):
Screenshot From 2026-03-09 12-40-22
  • Local renderer test run (PASS 5):
Screenshot From 2026-03-09 12-56-42

@ANAMASGARD
Copy link
Contributor Author

Sir @tdhock this is a pre-existing infrastructure issue , it has nothing to do with the code changes I ahve made , please review .

Error ('test-compiler-ghpages.R:59:3'): ...
Error in file(con, "r"): cannot open the connection
└─base::readLines(README.md)

@ANAMASGARD ANAMASGARD requested a review from tdhock March 9, 2026 09:42
@tdhock
Copy link
Collaborator

tdhock commented Mar 10, 2026

looks good
does it work for facet_wrap and horizontal spacing too?

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.

theme(panel.margin=grid::unit(positive_number, "lines")) should work

2 participants