Opened 3 years ago

Last modified 3 years ago

#25456 needs_work defect

Conversion error in Real Ball Fields

Reported by: vklein Owned by:
Priority: major Milestone: sage-8.3
Component: basic arithmetic Keywords: thursdaysbdx
Cc: slabbe, vdelecroix, mmezzarobba Merged in:
Authors: Vincent Delecroix Reviewers:
Report Upstream: N/A Work issues:
Branch: u/vdelecroix/25456 (Commits, GitHub, GitLab) Commit: 2d4ff247c437fc4d04599357e609b9d47135624c
Dependencies: Stopgaps:

Status badges

Description

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).

Change History (5)

comment:1 Changed 3 years ago by vklein

  • Status changed from new to needs_info

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.

Last edited 3 years ago by vklein (previous) (diff)

comment:2 Changed 3 years ago by vklein

  • Cc vdelecroix added
  • Keywords thursdaysbdx added

comment:3 Changed 3 years ago by vdelecroix

  • Authors set to Vincent Delecroix
  • Branch set to u/vdelecroix/25456
  • Cc mmezzarobba added
  • Commit set to 2d4ff247c437fc4d04599357e609b9d47135624c
  • Status changed from needs_info to needs_review

New commits:

2d4ff2425456: more generic real ball initialization

comment:4 Changed 3 years ago by mmezzarobba

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.

comment:5 Changed 3 years ago by mmezzarobba

  • Status changed from needs_review to needs_work
Note: See TracTickets for help on using tickets.