docs(core/utils): update docstrings for NA

Signed-off-by: Xuehai Pan <XuehaiPan@pku.edu.cn>
This commit is contained in:
Xuehai Pan 2022-07-29 15:52:11 +08:00
parent 877633cd04
commit dc562f503f
2 changed files with 22 additions and 10 deletions

View file

@ -997,17 +997,23 @@ Out[18]: MemoryInfo(total=268435456, free=257622016, used=10813440)
>>> from nvitop import NA
>>> NA
'N/A'
>>> 'memory usage: {}'.format(NA) # NA is an instance of `str`
'memory usage: N/A'
>>> NA + 'str'
>>> NA.lower() # NA is an instance of `str`
'n/a'
>>> NA.ljust(5) # NA is an instance of `str`
'N/A '
>>> NA + 'str' # string contamination if the operand is a string
'N/Astr'
>>> float(NA) # explicit conversion to float (`math.nan`)
>>> float(NA) # explicit conversion to float (`math.nan`)
nan
>>> NA + 1 # auto-casting to float
>>> NA + 1 # auto-casting to float if the operand is a number
nan
>>> NA * 1024 # auto-casting to float
>>> NA * 1024 # auto-casting to float if the operand is a number
nan
>>> NA / (1024 * 1024) # auto-casting to float
>>> NA / (1024 * 1024) # auto-casting to float if the operand is a number
nan
```

View file

@ -108,17 +108,23 @@ class NaType(str):
>>> NA
'N/A'
>>> 'memory usage: {}'.format(NA) # NA is an instance of `str`
'memory usage: N/A'
>>> NA + 'str'
>>> NA.lower() # NA is an instance of `str`
'n/a'
>>> NA.ljust(5) # NA is an instance of `str`
'N/A '
>>> NA + 'str' # string contamination if the operand is a string
'N/Astr'
>>> float(NA) # explicit conversion to float (`math.nan`)
>>> float(NA) # explicit conversion to float (`math.nan`)
nan
>>> NA + 1 # auto-casting to float
>>> NA + 1 # auto-casting to float if the operand is a number
nan
>>> NA * 1024 # auto-casting to float
>>> NA * 1024 # auto-casting to float if the operand is a number
nan
>>> NA / (1024 * 1024) # auto-casting to float
>>> NA / (1024 * 1024) # auto-casting to float if the operand is a number
nan
"""