Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul Unicode preferences #1586

Merged
merged 6 commits into from
Feb 5, 2024
Merged

Conversation

lgoettgens
Copy link
Collaborator

@lgoettgens lgoettgens commented Jan 30, 2024

To be able to disable unicode for tests/doctests etc., see e.g. oscar-system/Oscar.jl#3271

Resolves #1588.

Copy link

codecov bot commented Jan 30, 2024

Codecov Report

Attention: 22 lines in your changes are missing coverage. Please review.

Comparison is base (14b8c2b) 87.17% compared to head (6108fee) 87.14%.

Files Patch % Lines
src/PrettyPrinting.jl 0.00% 22 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1586      +/-   ##
==========================================
- Coverage   87.17%   87.14%   -0.04%     
==========================================
  Files         115      115              
  Lines       29565    29577      +12     
==========================================
+ Hits        25773    25774       +1     
- Misses       3792     3803      +11     

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

@lgoettgens
Copy link
Collaborator Author

This now contains the sketch by @fingolfin in #1588 as well with one difference: with_unicode does not longer call allow_unicode to be able to have multiple with_unicode stacked onto one another.
Furthermore, I noticed that calling allow_unicode from within a with_unicode block may have unintended results (due to the with_unicode finally clause). This is both in the current and in the updated form. I added this fact to the docstring of allow_unicode.

@lgoettgens lgoettgens changed the title Allow with_unicode(false) Overhaul Unicode preferences Feb 1, 2024
@thofma
Copy link
Member

thofma commented Feb 2, 2024

No clue (neither what the problem nor what the proposed solution is).

Does that address your concerns @benlorenz?

Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

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

Some optional suggestions added

src/PrettyPrinting.jl Outdated Show resolved Hide resolved
src/PrettyPrinting.jl Outdated Show resolved Hide resolved
src/PrettyPrinting.jl Outdated Show resolved Hide resolved
previous = ALLOW_UNICODE_OVERRIDE_VALUE
ALLOW_UNICODE_OVERRIDE_VALUE = flag
try
f()
Copy link
Member

Choose a reason for hiding this comment

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

Seems we have no tests for with_unicode in AA` :-(. But of course this is out of scope for this PR.

Copy link
Collaborator Author

@lgoettgens lgoettgens Feb 2, 2024

Choose a reason for hiding this comment

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

That's true. But after thinking again about it, this seems to be kind of hard anyway:
Calling allow_unicode() from the test would change the user preferences while running tests (not a great experience for devs), and from a within with_unicode block allow_unicode is unsafe.

But overall, we should postpone it

@lgoettgens
Copy link
Collaborator Author

All of this is non-breaking and can thus be merged, right?

Copy link
Collaborator

@benlorenz benlorenz left a comment

Choose a reason for hiding this comment

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

I would also prefer to have this as a const Ref, this should work with all supported julia versions. I think this avoids some performance penalty in the compiler since it can generate more specific code and it also avoids having to specify the global every time. I added suggestions for the remaining code.

Otherwise I think this should work for the Oscar tests.

src/PrettyPrinting.jl Outdated Show resolved Hide resolved
src/PrettyPrinting.jl Outdated Show resolved Hide resolved
src/PrettyPrinting.jl Outdated Show resolved Hide resolved
src/PrettyPrinting.jl Outdated Show resolved Hide resolved
@lgoettgens lgoettgens merged commit f7a5678 into Nemocas:master Feb 5, 2024
13 checks passed
@lgoettgens lgoettgens deleted the lg/with_unicode branch February 5, 2024 15:11
@lgoettgens lgoettgens mentioned this pull request Feb 5, 2024
ooinaruhugh pushed a commit to ooinaruhugh/AbstractAlgebra.jl that referenced this pull request Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants