Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion error in Real Ball Fields #25456

Closed
vinklein mannequin opened this issue May 28, 2018 · 8 comments
Closed

Conversion error in Real Ball Fields #25456

vinklein mannequin opened this issue May 28, 2018 · 8 comments

Comments

@vinklein
Copy link
Mannequin

vinklein mannequin commented May 28, 2018

Calling RBF with two parameters and using a sage Integer as radius provoke a TypeError.

sage: RBF(0,5.)
[+/- 5.01]
sage: RBF(0.,5.)
[+/- 5.01]
sage: RBF(0.,5)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-23-d3ae2a7cd5cc> in <module>()
----> 1 RBF(RealNumber('0.'),Integer(5))

/home/vklein/odk/sage/local/lib/python2.7/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9761)()
    920                 return mor._call_(x)
    921             else:
--> 922                 return mor._call_with_args(x, args, kwds)
    923 
    924         raise TypeError("No conversion defined from %s to %s"%(R, self))

/home/vklein/odk/sage/local/lib/python2.7/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.DefaultConvertMap_unique._call_with_args (build/cythonized/sage/structure/coerce_maps.c:5093)()
    162                 print(type(C), C)
    163                 print(type(C._element_constructor), C._element_constructor)
--> 164             raise
    165 
    166 

/home/vklein/odk/sage/local/lib/python2.7/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.DefaultConvertMap_unique._call_with_args (build/cythonized/sage/structure/coerce_maps.c:4933)()
    155             else:
    156                 if len(kwds) == 0:
--> 157                     return C._element_constructor(x, *args)
    158                 else:
    159                     return C._element_constructor(x, *args, **kwds)

/home/vklein/odk/sage/local/lib/python2.7/site-packages/sage/rings/real_arb.pyx in sage.rings.real_arb.RealBallField._element_constructor_ (build/cythonized/sage/rings/real_arb.c:6522)()
    523         except TypeError:
    524             pass
--> 525         raise TypeError("unable to convert {!r} to a RealBall".format(mid))
    526 
    527     def _repr_option(self, key):

TypeError: unable to convert 0 to a RealBall

Same error with RBF(0,5).

CC: @seblabbe @videlec @mezzarobba

Component: basic arithmetic

Keywords: thursdaysbdx

Author: Vincent Delecroix

Branch/Commit: u/vdelecroix/25456 @ 2d4ff24

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

@vinklein vinklein mannequin added this to the sage-8.3 milestone May 28, 2018
@vinklein
Copy link
Mannequin Author

vinklein mannequin commented May 31, 2018

comment:1

In the current RBF implementation rejecting Integers types as rad parameter seems intentional.

def __init__(self, parent, mid=None, rad=None):
        """
        Initialize the :class:`RealBall`.

        INPUT:

        - ``parent`` -- a :class:`RealBallField`.

        - ``mid`` (optional) --  ball midpoint, see examples below. If omitted,
          initialize the ball to zero, ignoring the ``rad`` argument.

        - ``rad`` (optional) -- a :class:`RealNumber` or a Python float, ball
          radius. If the midpoint is not exactly representable in
          floating-point, the radius is adjusted to account for the roundoff
          error.

Is there a good reason to keep it that way ? Any advices are welcome.

@vinklein vinklein mannequin added the s: needs info label May 31, 2018
@vinklein
Copy link
Mannequin Author

vinklein mannequin commented May 31, 2018

Changed keywords from none to thursdaysbdx

@videlec
Copy link
Contributor

videlec commented Jun 1, 2018

Author: Vincent Delecroix

@videlec
Copy link
Contributor

videlec commented Jun 1, 2018

New commits:

2d4ff2425456: more generic real ball initialization

@videlec
Copy link
Contributor

videlec commented Jun 1, 2018

Commit: 2d4ff24

@videlec
Copy link
Contributor

videlec commented Jun 1, 2018

Branch: u/vdelecroix/25456

@mezzarobba
Copy link
Member

comment:4

It would be nice to support more general radii, but:

  • There is no guarantee that converting to RealField(RNDA) really will compute an upper-approximation (think of nontrivial symbolic expressions). I guess coercing should, but I'm not even sure.
  • It would be more consistent with the current code to put the branch that goes though a (sage-level) conversion in _element_constructor_(), and reserve __init__() for initialization of the arb object.

@mkoeppe mkoeppe removed this from the sage-8.3 milestone Dec 29, 2022
@mezzarobba
Copy link
Member

duplicate of #23430

@mezzarobba mezzarobba closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants