Skip to content

Column wrapping tweaks#80

Merged
kyleam merged 3 commits intomainfrom
matrix-tweak-widths
Apr 9, 2025
Merged

Column wrapping tweaks#80
kyleam merged 3 commits intomainfrom
matrix-tweak-widths

Conversation

@kyleam
Copy link
Collaborator

@kyleam kyleam commented Apr 8, 2025

When preparing to use mpn.scorecard for Torsten, some of entry points in the matrix ran into the next column. The main purpose of this PR is to avoid that by decreasing the specified column width [*]. (See last commit for information.)

In addition, this PR makes two more wrapping tweaks:

  • for strict mode, prefer breaking at mid-string capital letters

    This relates to the decreased column width. With the width change, I noticed that review's diffPreviousRevisions was getting unpleasantly wrapped so that the final s was on the second line. By considering mid-string capital letters, the break instead happens before Revisions.

  • add space to the default wrap_sym value

    This makes it more likely that CLI entry points find a good break point, which becomes more relevant as we decrease the widths. (However, none of the CLIs that we currently score have entry points that exceed the new width, so it doesn't matter at this point.)

[*] note added after this was merged, to hopefully reduce chance of confusion when we revisit this: "column width" is confusing word choice. It's referring to the number of characters at which a value is wrapped (i.e. the width value passed to wrap_text). This PR does not decrease the width of the table columns themselves (which would make it more likely a value would run outside the column boundary!).

kyleam added 3 commits April 8, 2025 14:59
When rendering a scorecard for command line programs, the entry point
will frequently have spaces (e.g., "bbi nonmem run local").
Under strict=TRUE, wrap_text first tries to get the string under the
specified width by splitting at the wrap_sym characters and then falls
back to breaking the string at whatever positions are necessary to get
the string under the specified width.

If the package uses camelCase for their functions, it's more readable
to split before the capital letter.  For example,

    diffPrevious
      Revisions

looks better than

    diffPreviousRevision
      s

Try splitting at mid-string capital letters before breaking the string
at any character.
When preparing to score Torsten, a few entry points are running into
the next column (e.g., pmx_solve_group_adams).

Ideally, we'd be able to avoid these problems by choosing a width
where we know the column can fit any string with fewer characters.
For example, with the current variable-width font, W is the widest
letter.  Using long runs of Ws as dummy values for each column, I was
able to get the values to fit by specifying widths of 9 (instead of
24) and 17 (instead of 27) for the non-test columns and test column,
respectively.

Although those values should prevents any text from running over, they
unfortunately lead to excessive and very bad looking breaks for
realistic names.

At least until we come up with a better approach, just reduce the
width to make the Torsten matrix not have values that run over the
column boundary.
@kyleam kyleam requested review from barrettk and seth127 April 8, 2025 20:28
Copy link
Collaborator

@barrettk barrettk left a comment

Choose a reason for hiding this comment

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

This looks good and thanks for the detailed commit messages.

I like the capital letter fallback. The letters example you sent offline makes me wonder if we should consider exposing the width argument via a ... argument at some point so that this could be adjusted for specific packages in the MPN build toolchain - would that be helpful?

Additionally, the letters seem to go off the page for the test files:
image

@kyleam
Copy link
Collaborator Author

kyleam commented Apr 9, 2025

if we should consider exposing the width argument via a ... argument at some point so that this could be adjusted for specific packages in the MPN build toolchain - would that be helpful?

You say "MPN build toolchain"; no, I don't think exposing an argument or worrying about widths is something that we should be concerned with in the context of MPN.

However, for MetrumRG scorecards, we do want to make sure nothing runs over. Seth raised a similar point offline about whether it'd be good to expose an argument. I'm not against it, though I think it'd take more thought and work to make useful.

Exposing the width as an argument or option would make it possible to resolve a runoff issue without an mpn.release and even possible to have different widths per package. But that would then involve exposing those through our internal driver script, and, if we were planning on using different widths per package (rather than using the argument for a temporary fix before a adjusting mpn.scorecard), we would need to store those configurations somewhere so the caller didn't have to remember/know to specify some width value.

So, perhaps, but at this point I think we should just adjust the width and revisit the idea if we hit into this problem again.

Additionally, the letters seem to go off the page for the test files:

Yes, the letter example shows cases that go off for all columns. The point I'm making with that letter example is that we'd need to adjust to excessively small widths to get nothing to run off.

From 4e488f6:

[...] For example, with the current variable-width font, W is the widest
letter.  Using long runs of Ws as dummy values for each column, I was
able to get the values to fit by specifying widths of 9 (instead of
24) and 17 (instead of 27) for the non-test columns and test column,
respectively.

Although those values should prevents any text from running over, they
unfortunately lead to excessive and very bad looking breaks for
realistic names.

Test files aren't running off in any known examples, so I don't see a reason to adjust the column width (just like I don't think we should farther adjust the non-test columns even though some letters still run off).

@kyleam
Copy link
Collaborator Author

kyleam commented Apr 9, 2025

Another thing worth considering at some point: switching the matrix table and perhaps other tables to use fixed-width font. That should allow us to determine a single column/character width that is sufficient to avoid running over. Aside from cosmetics of getting that font change accepted, an open question is whether the determined value would lead to reasonable looking wrapping as opposed to the excessive wrapping that's needed to get the variable-width letter example (in particular a string of Ws) to not run off.

@barrettk barrettk self-requested a review April 9, 2025 19:13
Copy link
Collaborator

@barrettk barrettk left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for the replies

@kyleam
Copy link
Collaborator Author

kyleam commented Apr 9, 2025

@barrettk Thanks for the review.

@kyleam kyleam merged commit e5801ff into main Apr 9, 2025
5 checks passed
@kyleam kyleam deleted the matrix-tweak-widths branch April 9, 2025 19:19
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