Skip to content

Complex number printing inconsistent with float #33494

@anjali411

Description

@anjali411

Zeros and tensor printing for float and complex

  1. In float tensor print, the trailing zeros ( with precision 4) are printed only when there’s one or more digit after decimal or otherwise just a decimal is printed
  2. In complex tensor print rn, the trailing zeros are printing in all cases

torch.zeros((2,2), dtype=torch.float64)
tensor([[0., 0.],
[0., 0.]], dtype=torch.float64)

torch.tensor([1.2, 1.340], dtype=torch.float64)
tensor([1.2000, 1.3400], dtype=torch.float64)

torch.tensor([1, 1], dtype=torch.float64)
tensor([1., 1.])

torch.zeros((2,2), dtype=torch.complex64)
tensor([[(0.0000 + 0.0000), (0.0000 + 0.0000j)],
[(0.0000 + 0.0000j), (0.0000 + 0.0000j)]], dtype=torch.complex64)

torch.tensor([1.2 + 1.340], dtype=torch.complex64)
tensor([1.2000 + 1.3400j], dtype=torch.complex64)

torch.tensor([1, 1], dtype=torch.complex64)
tensor([1.0000, 1.0000], , dtype=torch.complex64)

cc @ezyang @anjali411 @dylanbespalko

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issuemodule: complexRelated to complex number support in PyTorchmodule: printingIssues related to the printing format of tensorstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions