Genesis icon indicating copy to clipboard operation
Genesis copied to clipboard

Fix:Remove ANSI sequences and format issues in RBC.__repr

Open JonnyDing opened this issue 11 months ago • 1 comments
trafficstars

Problem description

ANSI escape sequences (color and format control characters) used in the __repr__ method may appear garbled in unsupported environments in debugging or terminal output, affecting the readability of debugger output or logging.

Problem

  • The console of a debugger such as PyCharm or VSCode does not parse ANSI escape sequences correctly.
  • Attribute values are displayed inconsistently across multiple lines, with some members being displayed as “gibberish”.
  • Some property values may throw exceptions when accessed, resulting in no display. before

Changes

Determine whether the current environment is a debug environment, so as to solve the problem of ANSI garbled code in the debug environment.

Example of modified output:

<gs.Scene> t=<int>: 0 dt=<float>: 0.02 requires_grad=<bool>: False substeps=<int>: 2 visualizer=<gs.
![after](https://github.com/user-attachments/assets/b8d3a6d9-d9f3-4ccf-988c-7f7e6d607545)


JonnyDing avatar Dec 21 '24 07:12 JonnyDing

Problem description

ANSI escape sequences (color and format control characters) used in the __repr__ method may appear garbled in unsupported environments in debugging or terminal output, affecting the readability of debugger output or logging.

Problem

  • The console of a debugger such as PyCharm or VSCode does not parse ANSI escape sequences correctly.
  • Attribute values are displayed inconsistently across multiple lines, with some members being displayed as “gibberish”.
  • Some property values may throw exceptions when accessed, resulting in no display. before

Changes

Determine whether the current environment is a debug environment, so as to solve the problem of ANSI garbled code in the debug environment.

Example of modified output: after

JonnyDing avatar Dec 21 '24 07:12 JonnyDing

Looks useful! @zswang666 could you double check and merge?

zhouxian avatar Dec 21 '24 16:12 zhouxian