File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change 1616import numpy as np
1717import warnings
1818import weakref
19+ import sys
1920
2021import paddle
2122from .. import framework
@@ -372,6 +373,9 @@ def grad(self):
372373 """
373374 msg = "tensor.grad will return the tensor value of the gradient."
374375 warning_msg = "\033 [93m\n Warning:\n %s \033 [0m" % (msg )
376+ # ensure ANSI escape sequences print correctly in cmd and powershell
377+ if sys .platform .lower () == 'win32' :
378+ warning_msg = "\n Warning:\n %s " % (msg )
375379 warnings .warn (warning_msg )
376380 return self ._grad_ivar ()
377381
Original file line number Diff line number Diff line change 1818import warnings
1919import functools
2020import paddle
21+ import sys
2122
2223__all__ = []
2324
@@ -99,6 +100,10 @@ def wrapper(*args, **kwargs):
99100 func .__module__ , func .__name__ ))
100101
101102 warningmsg = "\033 [93m\n Warning:\n %s \033 [0m" % (msg )
103+ # ensure ANSI escape sequences print correctly in cmd and powershell
104+ if sys .platform .lower () == 'win32' :
105+ warningmsg = "\n Warning:\n %s " % (msg )
106+
102107 v_current = [int (i ) for i in paddle .__version__ .split ("." )]
103108 v_current += [0 ] * (4 - len (v_current ))
104109 v_since = [int (i ) for i in _since .split ("." )]
You can’t perform that action at this time.
0 commit comments