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

pynac bug -- evaluation of arctan2 fails with traceback #22553

Closed
williamstein opened this issue Mar 9, 2017 · 15 comments
Closed

pynac bug -- evaluation of arctan2 fails with traceback #22553

williamstein opened this issue Mar 9, 2017 · 15 comments

Comments

@williamstein
Copy link
Contributor

~/Sara$ sage-develop
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 7.6.beta5, Release Date: 2017-02-26               │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable.     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
sage: arctan2(1.5,-1.300000000000001)
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-1-ccfa336aad7e> in <module>()
----> 1 arctan2(RealNumber('1.5'),-RealNumber('1.300000000000001'))
 
/projects/sage/sage-dev/src/sage/symbolic/function.pyx in sage.symbolic.function.BuiltinFunction.__call__ (/projects/sage/sage-dev/src/build/cythonized/sage/symbolic/function.cp
p:11445)()
    994             res = self._evalf_try_(*args)
    995             if res is None:
--> 996                 res = super(BuiltinFunction, self).__call__(
    997                         *args, coerce=coerce, hold=hold)
    998
 
/projects/sage/sage-dev/src/sage/symbolic/function.pyx in sage.symbolic.function.Function.__call__ (/projects/sage/sage-dev/src/build/cythonized/sage/symbolic/function.cpp:6589)
()
    489                     (<Expression>args[0])._gobj, hold)
    490         elif self._nargs == 2:
--> 491             res = g_function_eval2(self._serial, (<Expression>args[0])._gobj,
    492                     (<Expression>args[1])._gobj, hold)
    493         elif self._nargs == 3:
 
/projects/sage/sage-dev/src/sage/libs/pynac/pynac.pyx in sage.libs.pynac.pynac.py_atan2 (/projects/sage/sage-dev/src/build/cythonized/sage/libs/pynac/pynac.cpp:21075)()
   1790     if P is float and parent(y) is not float:
   1791         P = RR
-> 1792     assert P is parent(y)
   1793     if P is ZZ:
   1794         P = RR
 
AssertionError:

In fact, pretty much any high precision input (even just padding with zeros) breaks this:

sage: atan2(2.1000000000000000000000000000000000000,-1.20000000000000000000000000000000)
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)

Reported by: Sara Billey

CC: @paulmasson @rwst

Component: calculus

Author: Ralf Stephan, Jeroen Demeyer

Branch/Commit: a41922c

Reviewer: Jeroen Demeyer, Paul Masson

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

@williamstein williamstein added this to the sage-7.6 milestone Mar 9, 2017
@rwst
Copy link

rwst commented Mar 9, 2017

comment:3

This was introduced in #21371. Not Pynac but its Python interface to Sage's numeric functions.

@rwst
Copy link

rwst commented Mar 9, 2017

@rwst
Copy link

rwst commented Mar 9, 2017

Author: Ralf Stephan

@rwst
Copy link

rwst commented Mar 9, 2017

Commit: 64e05e5

@rwst
Copy link

rwst commented Mar 9, 2017

New commits:

64e05e522553: remove assert

@jdemeyer
Copy link

jdemeyer commented Mar 9, 2017

comment:6

Why not use

from sage.structure.element cimport coercion_model

P = coercion_model.common_parent(x, y)

@jdemeyer
Copy link

jdemeyer commented Mar 9, 2017

Reviewer: Jeroen Demeyer

@jdemeyer
Copy link

jdemeyer commented Mar 9, 2017

comment:7

I'll make that change and some further changes.

@jdemeyer
Copy link

jdemeyer commented Mar 9, 2017

Changed commit from 64e05e5 to a41922c

@jdemeyer
Copy link

jdemeyer commented Mar 9, 2017

New commits:

a41922cMinor fixes to py_atan2

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Mar 9, 2017

comment:10

Jeroen, nice work on this. I've been devising ways to get around this assertion error for some time so it's nice to be rid of it. This is an elegant solution and the code cleanup looks good.

A run of make ptestlong produced the following errors:

sage -t --long src/sage/libs/ppl.pyx  # Timed out after testing finished
sage -t --long src/sage/misc/sagedoc.py  # 3 doctests failed

The ppl.pyx error went away on a subsequent test of just that file. Strangely enough, so did the sagedoc.py errors, so I guess we're good to go.

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Mar 9, 2017

Changed author from Ralf Stephan to Ralf Stephan, Jeroen Demeyer

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Mar 9, 2017

Changed reviewer from Jeroen Demeyer to Jeroen Demeyer, Paul Masson

@vbraun
Copy link
Member

vbraun commented Mar 10, 2017

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

4 participants