-
Notifications
You must be signed in to change notification settings - Fork 17
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
ANSI colors not disabled when displaying values in PyCharm inline hints. #20
Comments
On the pycharm console it looks the same. I should have pointed out that the error in visualization is in debug mode, when I try to check the content of a tensor. |
Ah, yeah, the vscode debugger does the same thing, it can't handle colors. I have fixed it in git, but just realized that I did not release a new version since then. I'll do it later today. If you'd like to, you can install lovely-tensors and lovely-numpy from git for now. |
I will do that, thank you very much! |
@nicofirst1 , I've pushed out a new release. It's in pip now, and will be updated in conda-forge in a bit. |
Hey @xl0 , I've updated to version 0.1.15, but I'm still experiencing the same issue. But only on the line visualization of debug mode. Attached a screenshot of my code. |
This is quite strange. Once LT detects that it's running in the debugger, it will disable the colours. My code: def in_debugger():
"""Returns True if a debugger was used.
Note: This funciton will keep returning True even after you exit the debugger."""
return getattr(sys, "gettrace", None) and sys.gettrace() is not None Here similar functionality works in vscode: (kinda works - it updates the previous appearances of the variable to its latest value, which might be super confusing) In your case, does from lovely_numpy.utils import in_debugger
in_debugger() return true? If you want a workaround, you can just disable colours completely: But I'd love to get it working automatically. Do you know how we could detect if LT is in the pycharm hint mode? |
|
To be clear, the inline value hint is displayed when debugging, right? |
This does not make a lot of sense to me. The code is pretty straightforward:
So, PyCharm must be exiting debug mode, cleans up the global namespace to make it impossible to detect that the debugger was used after the fact (something vscode forgets to do, so once you run in debug mode, you lose colours), and only then fetches the repr value of the variable? Maybe you could ping the PyCharm people and ask about ANSI colours in repr? |
Problem Description
Using lovely-tensors with torch, when some Nan values are present in the tensor, I see the following:
Other symbols, such as mean and std, are shown correctly:
What I've tried
System info
lovely-tensors : 0.1.14
IDE : Pycharm Professional 2023.1
Font : FiraCode Nerd Font
Encoding : UTF-8
torch: 1.11.0+cu102
The text was updated successfully, but these errors were encountered: