-
Notifications
You must be signed in to change notification settings - Fork 370
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
Display complex numbers - alignment #2754
Comments
The corner case is bare
but I guess that could be handled. Also I guess we can ensure handling of of complex alignment for columns that have complex eltype (possibly a union with |
Ok! It should be easy (except for the missing part). |
Well, we can do this:
The idea here is to avoid the last regex as much as we can. It uses conditionals and lookbehind, which tends to be very slow. Using this selection of regexes, we have: julia> DataFrame(Test_Integer=[123+5im, 45-56im, 1-234im], Test_Float=[1.234+2.3im, 12.1-23.4im, 1.3-1.456im], Test_Number=Number[12.1-23.4im, 1//3+4//5im, 45-56im]) julia> a = Union{Missing, Number}[im, 1 + im, -1 - im, 1.123 + 123im, -2.323 - 32im, -1//3 - 4//5im, 1028.23123, missing, randn(), 2123123, rand()];
julia> b = [10^(i-1) for i = 1:11];
julia> c = [i == 5 ? missing : 10.0^(i-4) for i = 1:11];
julia> DataFrame(a = a, b = b, c = c) Notice that this is the best I can do at the moment with the |
Oops, I forgot that we can have |
Done! I really need help testing this new algorithm to check if all corner cases were handled. |
@ronisbr - thank you for working on this. I will have a look at the branch in more detail later this week. My fear is to avoid making a super complex algorithm for the case that is very rarely needed, so @strickek - could you please have a look at #2756 also and comment which cases are actually useful in practice? Thank you! |
I fully understand your concern. In fact, using those complex regexes can backfire if we did not see a corner case. The biggest problem is that it can affect things that are working. That's why I split the regex depending on the column specialization. |
Agreed - let us wait for @strickek to comment what is really needed and minimize the changes I think (otherwise in 5 years no one will understand the logic we have here). |
IMHO the alignment of complex numbers can be kept. It is contained for columns that are
The latter is the current version, but it does has problems if the column contains complex numbers. |
I would go for:
|
I agree. Number was from an old test. <complex is ok. |
I agree number is not necessary, so I would also skip case nr 4). Thank you for your fast solution. |
OK! I will change the PR. |
Actual for Complex[Float64] the decimal of the real part is used as anchor (whole imaginary part right of it), complex without decimal are printed like pre-decimal places:
For complex numbers I suggest to use the sign of the imaginary part as anchor, so the example above would look this way:
Code for example:
DataFrame(Test_Integer=[123+5im, 45-56im, 1-234im], Test_Float=[1.234+2.3im, 12.1-23.4im, 1.3-1.456im], Test_Number=Number[12.1-23.4im, 1//3+4//5im, 45-56im])
The text was updated successfully, but these errors were encountered: