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

[BUG] inconsistent coloring of complex numbers #2214

Closed
flaport opened this issue Apr 22, 2022 · 7 comments · Fixed by #2219
Closed

[BUG] inconsistent coloring of complex numbers #2214

flaport opened this issue Apr 22, 2022 · 7 comments · Fixed by #2219
Assignees
Labels
accepted Task was accepted

Comments

@flaport
Copy link

flaport commented Apr 22, 2022

Not sure if I should report this as a bug or as a feature request, but there is a very minor issue when printing complex numbers: the decimal part of the imaginary number is uncolored.

try for example:

>>> from rich import pretty
>>> pretty.install()
>>> 3.05 + 2.06j
(3.05+2.06j)

image

I tried this on Linux, rich version 12.2.0. This "bug" appears both in the terminal (alacritty in my case) as well as in jupyter notebooks, which makes me believe it is platform independent.

@willmcgugan
Copy link
Collaborator

Rich doesn't have any explicit supports for complex numbers. If you're adept with regexes, you could add it to highlighter.py

@flaport
Copy link
Author

flaport commented Apr 22, 2022

Thanks will, I'll try that.

However, respectfully, complex numbers are natively supported by python so in my opinion they should also be natively supported by the rich pretty printer. Having to specify the same regex over and over in interactive sessions (which many scientific exploratory notebooks are for example) is not really user friendly...

Like I said, it's a very minor issue and I understand that adding this feature might yield unnecessary overhead on your side. If that's the case just disregard it, but I think as rich will become more popular in the scientific community you might get this question again.

@willmcgugan
Copy link
Collaborator

I was actually suggesting that you could contribute this to highlighter.py in the repo, if you could come up with the regex. I'm happy to add it.

@flaport
Copy link
Author

flaport commented Apr 22, 2022

Sure! I'll give it a shot 🙂

@olivierphi
Copy link
Contributor

Hi @flaport ! 🙂
Just a quick message to let you know that the issue is fixed now, and should be merged soon. Thank you for your report! :-)

#2219

@flaport
Copy link
Author

flaport commented Apr 25, 2022

Ai, lost my opportunity to contribute to this awesome library 😉. Thanks a lot for this quick resolution!

@github-actions
Copy link

Did I solve your problem?

Why not buy the devs a coffee to say thanks?

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

Successfully merging a pull request may close this issue.

4 participants