use UOp.render in colored_shape (#7321)

similar to function name, print rendered str instead of raw UOp
This commit is contained in:
chenyu
2024-10-27 11:42:31 -04:00
committed by GitHub
parent 4a03e00aa1
commit cdbe08b94b

View File

@@ -190,7 +190,8 @@ class Kernel:
return colors
def colored_shape(self, pad:Optional[int]=None, dense=False) -> str:
ret = ' '.join(colored(s, color) for s,color in zip([f"{s:4d}" if isinstance(s, int) and not dense else s for s in self.full_shape], self.colors())) # noqa: E501
shape_strs = [(s if dense else f"{s:4d}") if isinstance(s, int) else s.render() for s in self.full_shape]
ret = ' '.join(colored(s, color) for s,color in zip(shape_strs, self.colors()))
if pad: ret += ' '*(pad-ansilen(ret))
return ret