#16436: is_real method should exist for elements of AA, ZZ, QQ
-------------------------------+------------------------
Reporter: slabbe | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: sage-6.3
Component: algebra | Resolution:
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
-------------------------------+------------------------
Description changed by slabbe:
Old description:
> The function ``is_real`` is useful but it is not practical because it it
> not implemented for every types of numbers in Sage. And I do not want to
> do type checking before being able to use it in my code.
>
> {{{
> sage: CC(3).is_real()
> True
> sage: RR(3).is_real()
> True
> sage: SR(3).is_real()
> True
> sage: ZZ(3).is_real()
> Traceback (most recent call last):
> ...
> AttributeError: 'sage.rings.integer.Integer' object has no attribute
> 'is_real'
> sage: QQ(3).is_real()
> Traceback (most recent call last):
> ...
> AttributeError: 'sage.rings.rational.Rational' object has no attribute
> 'is_real'
> sage: AA(3).is_real()
> Traceback (most recent call last)
> ...
> AttributeError: 'AlgebraicReal' object has no attribute 'is_real'
> }}}
>
> I am sure I forget some other rings...
>
> We need more of this kind of consistency in Sage. ``is_imaginary`` is
> another example.
New description:
The function ``is_real`` is useful but it is not practical because it it
not implemented for every types of numbers in Sage. And I do not want to
do type checking before being able to use it in my code.
{{{
sage: CC(3).is_real()
True
sage: RR(3).is_real()
True
sage: SR(3).is_real()
True
sage: ZZ(3).is_real()
Traceback (most recent call last):
...
AttributeError: 'sage.rings.integer.Integer' object has no attribute
'is_real'
sage: QQ(3).is_real()
Traceback (most recent call last):
...
AttributeError: 'sage.rings.rational.Rational' object has no attribute
'is_real'
sage: AA(3).is_real()
Traceback (most recent call last)
...
AttributeError: 'AlgebraicReal' object has no attribute 'is_real'
sage: AlgebraicNumber(3).is_real()
Traceback (most recent call last)
...
AttributeError: 'AlgebraicNumber' object has no attribute 'is_real'
}}}
I am sure I forget some other rings...
We need more of this kind of consistency in Sage. ``is_imaginary`` is
another example.
--
--
Ticket URL: <http://trac.sagemath.org/ticket/16436#comment:2>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.