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

Alignment of complex numbers #2756

Merged
merged 9 commits into from
May 16, 2021
Merged

Alignment of complex numbers #2756

merged 9 commits into from
May 16, 2021

Conversation

ronisbr
Copy link
Member

@ronisbr ronisbr commented May 10, 2021

Hi!

This PR should fix #2754 . However, it adds somewhat complex regexes, which can decrease performance, and have some corner case that I did not think of. Thus, I need help testing this algorithm :)

@ronisbr ronisbr changed the title Complex numbers Alignment of complex numbers May 10, 2021
@bkamins bkamins added this to the 1.x milestone May 10, 2021
@ronisbr
Copy link
Member Author

ronisbr commented May 10, 2021

Oops, I need to fix an overflow in the tests.

@strickek
Copy link

In "very_big_column_name_4" there should also be a test case with negative real part.
I think the '|' in the REGEX of alignment_regex_complex (line 200) can be deleted (no need to match for this Char).

@ronisbr
Copy link
Member Author

ronisbr commented May 11, 2021

In "very_big_column_name_4" there should also be a test case with negative real part.
I think the '|' in the REGEX of alignment_regex_complex (line 200) can be deleted (no need to match for this Char).

Good catch! I have updated the code. Let's see if the test passes.

test/show.jl Show resolved Hide resolved
@bkamins
Copy link
Member

bkamins commented May 11, 2021

@nalimilan - can you please have a quick look if you agree with the rules used?

Copy link
Member

@nalimilan nalimilan left a comment

Choose a reason for hiding this comment

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

Makes sense. Just a few style comments.

(Ideally I would say that in addition to aligning on the sign of the imaginary parts, the real parts should be aligned like real numbers, and imaginary parts should be aligned like real numbers, but Base doesn't do this either since that would require adding spaces in the middle of the number...)

test/show.jl Outdated Show resolved Hide resolved
test/show.jl Outdated Show resolved Hide resolved
test/show.jl Outdated Show resolved Hide resolved
test/show.jl Outdated Show resolved Hide resolved
ronisbr and others added 2 commits May 14, 2021 22:01
@ronisbr
Copy link
Member Author

ronisbr commented May 15, 2021

(Ideally I would say that in addition to aligning on the sign of the imaginary parts, the real parts should be aligned like real numbers, and imaginary parts should be aligned like real numbers, but Base doesn't do this either since that would require adding spaces in the middle of the number...)

Yes, this would be good but involve some changes in PrettyTables.jl. What we need to implement is the support for multiple anchors, so that we can have multiple alignments. It is not an easy task.

I think I resolved all @nalimilan's comments!

@bkamins
Copy link
Member

bkamins commented May 15, 2021

It is not an easy task.

This is what I would imagine. I would leave it for later. I think we have more pivotal functionalities (like HTML/LaTeX support) that should get a higher priority.

@bkamins
Copy link
Member

bkamins commented May 16, 2021

@ronisbr - OK to merge?

@ronisbr
Copy link
Member Author

ronisbr commented May 16, 2021

Yes!

@bkamins bkamins merged commit 85da3d7 into JuliaData:main May 16, 2021
@bkamins
Copy link
Member

bkamins commented May 16, 2021

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display complex numbers - alignment
4 participants