Skip to content

Fix complex handling of libs/pynac/py_float() #23077

@rwst

Description

@rwst

The goal is to always return some float, either real or complex but:

sage: from sage.libs.pynac.pynac import py_float_for_doctests as py_float
sage: py_float(I, {'parent':RealField(10)})
...
TypeError: unable to convert '1.0*I' to a real number

The code shows it's only done if there is no parent given:

    if kwds is not NULL:
        return (<object>kwds)['parent'](n)
    else:
        try:
            return RR(n)
        except TypeError:
            return CC(n)

The ticket should make it possible to fall back on the associated complex field of any parent.

Depends on #23145

Component: interfaces

Author: Ralf Stephan

Branch/Commit: 856f8dd

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/23077

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions