Skip to content

Fix complex.__repr__ handling of nan. #3182

Closed

Description

@DimitrisJim

Specifically two related issues:

  • Nan's should be lowercased (similar to Repr value for nan #3034)
  • Signs for nan should be included (always +), an issue really if the real part of the complex number is != 0.

For example, in Python:

>>> complex(0, float('nan'))
nanj
>>> complex(float('nan'), float('nan'))
(nan+nanj)
>>> complex(float('nan'), -float('nan'))
(nan+nanj)
>>> complex(-float('nan'), float('nan'))
(nan+nanj)

while in RustPython:

>>>>> complex(0, float('nan'))
NaNj
>>>>> complex(float('nan'), float('nan'))
(NaNNaNj)
>>>>> complex(float('nan'), -float('nan'))
(NaNNaNj)
>>>>> complex(-float('nan'), float('nan'))
(NaNNaNj)

Activity

  1. mdegis commented on Oct 1, 2021

    @mdegis

    I think I can work on this 👍

  2. removed their assignment
    on Oct 7, 2021
  3. linked a pull request that will close this issueFix complex::repr to use floats_ops. #3247on Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions