Skip to content

Install Sage on Travis using conda-forge#14703

Merged
asmeurer merged 18 commits intosympy:masterfrom
asmeurer:sage-travis
May 27, 2018
Merged

Install Sage on Travis using conda-forge#14703
asmeurer merged 18 commits intosympy:masterfrom
asmeurer:sage-travis

Conversation

@asmeurer
Copy link
Copy Markdown
Member

@asmeurer asmeurer commented May 8, 2018

(Hopefully) fixes #13395.

asmeurer added 2 commits May 8, 2018 14:57
Move it to the Python 2.7 optional dependency build, which isn't in
allowed_failures. If the conda install works, it shouldn't fail any more.
@asmeurer
Copy link
Copy Markdown
Member Author

asmeurer commented May 8, 2018

Test failure. Looks like an issue with the sage package.

+sage -t sympy/external/tests/test_sage.py
Traceback (most recent call last):
  File "/home/travis/miniconda/envs/test-environment/bin/sage-runtests", line 123, in <module>
    from sage.doctest.control import DocTestController
  File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/sage/doctest/control.py", line 33, in <module>
    from .sources import FileDocTestSource, DictAsObject
  File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/sage/doctest/sources.py", line 33, in <module>
    from .parsing import SageDocTestParser
  File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/sage/doctest/parsing.py", line 56, in <module>
    from sage.all import RealIntervalField
  File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/sage/all.py", line 98, in <module>
    from sage.rings.all      import *
  File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/sage/rings/all.py", line 54, in <module>
    from .number_field.all import *
  File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/sage/rings/number_field/all.py", line 9, in <module>
    from .totallyreal import enumerate_totallyreal_fields_prim
  File "sage/rings/number_field/totallyreal_data.pxd", line 12, in init sage.rings.number_field.totallyreal
  File "sage/rings/number_field/totallyreal_data.pyx", line 41, in init sage.rings.number_field.totallyreal_data
  File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/sage/rings/polynomial/polynomial_ring_constructor.py", line 585, in PolynomialRing
    return _single_variate(base_ring, names, **kwds)
  File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/sage/rings/polynomial/polynomial_ring_constructor.py", line 665, in _single_variate
    R = m.PolynomialRing_integral_domain(base_ring, name, sparse, implementation)
  File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/sage/rings/polynomial/polynomial_ring.py", line 1600, in __init__
    sparse=sparse, element_class=element_class, category=category)
  File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/sage/rings/polynomial/polynomial_ring.py", line 1471, in __init__
    sparse=sparse, element_class=element_class, category=category)
  File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/sage/rings/polynomial/polynomial_ring.py", line 288, in __init__
    from sage.matrix.matrix_space import MatrixSpace
  File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/sage/matrix/matrix_space.py", line 48, in <module>
    from . import matrix_modn_sparse
  File "sage/matrix/matrix_integer_dense.pxd", line 10, in init sage.matrix.matrix_modn_sparse
  File "sage/matrix/matrix_modn_dense_template_header.pxi", line 8, in init sage.matrix.matrix_integer_dense
ImportError: /home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/sage/matrix/../../../../liblinboxsage.so.0: undefined symbol: _ZN6FFPACK7MinPolyIN6Givaro7ModularIddEESt6vectorIdSaIdEEEERT0_RKT_S8_mNS9_16ConstElement_ptrEmNS9_11Element_ptrEmPmNS_18FFPACK_MINPOLY_TAGEmmm

CC @isuruf

@asmeurer
Copy link
Copy Markdown
Member Author

asmeurer commented May 9, 2018

It also occurs to me that sage is going to install SymPy, so we should probably remove it before continuing to make sure the conda SymPy isn't used in the tests.

@asmeurer
Copy link
Copy Markdown
Member Author

asmeurer commented May 9, 2018

Now it fails with

+sage -t sympy/external/tests/test_sage.py
Traceback (most recent call last):
  File "/home/travis/miniconda/envs/test-environment/bin/sage-runtests", line 124, in <module>
    DC = DocTestController(options, args)
  File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/sage/doctest/control.py", line 331, in __init__
    for pkg in list_packages('optional', local=True).values():
  File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/sage/misc/package.py", line 226, in list_packages
    installed = installed_packages(exclude_pip)
  File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/sage/misc/package.py", line 288, in installed_packages
    installed.update(pkgname_split(pkgname) for pkgname in os.listdir(SAGE_SPKG_INST))
OSError: [Errno 2] No such file or directory: '/home/travis/miniconda/envs/test-environment/var/lib/sage/installed'

Is this the same issue described here #13395 (comment)?

@isuruf
Copy link
Copy Markdown
Member

isuruf commented May 9, 2018

No this is being worked on by @saraedum at https://github.com/conda-forge/sagelib-feedstock/pull/20/files for sage-8.2. sage-8.3 has built in support I think.

asmeurer added 2 commits May 9, 2018 13:48
That way we don't accidentally test against it. SymPy will be installed
because of Sage.
@asmeurer
Copy link
Copy Markdown
Member Author

asmeurer commented May 9, 2018

Great. Ping me when this is ready to test again.

@isuruf
Copy link
Copy Markdown
Member

isuruf commented May 11, 2018

@asmeurer, it should be fixed now.

@Abdullahjavednesar Abdullahjavednesar added the PR: author's turn The PR has been reviewed and the author needs to submit more changes. label May 11, 2018
@asmeurer
Copy link
Copy Markdown
Member Author

Still the same error.

@isuruf
Copy link
Copy Markdown
Member

isuruf commented May 12, 2018

It's installing 8.1-py27_blas_openblas_0 instead of 8.1-py27_blas_openblas_2. Not sure why

@asmeurer
Copy link
Copy Markdown
Member Author

Usually that means that the version you want has incompatible dependencies. If you have Linux, you can try running the conda install (conda create ... --dry-run) explicitly setting sagelib=8.1=py27_blas_openblas_2 and it should tell you why it can't do it.

@isuruf
Copy link
Copy Markdown
Member

isuruf commented May 12, 2018

autowrap needs cython==0.21, while sagelib build number 2 requires cython>=0.27

@asmeurer
Copy link
Copy Markdown
Member Author

Ah. We should try to see if we can update cython. We should be testing against the latest versions of things anyway.

@asmeurer
Copy link
Copy Markdown
Member Author

There are some updates in the feedstock pull requests https://github.com/conda-forge/autowrap-feedstock/pulls. I wonder if we can remove the pin.

Miniconda-latest is an ancient version of miniconda.
@asmeurer
Copy link
Copy Markdown
Member Author

Still the same error.

@asmeurer asmeurer added this to the SymPy 1.2 milestone May 17, 2018
@isuruf
Copy link
Copy Markdown
Member

isuruf commented May 17, 2018

It's still using the old sagelib build. Don't know why

@asmeurer
Copy link
Copy Markdown
Member Author

It looks like it is able to install the correct sage this time. But now the build is running out of disk space! How much disk space do you get on Travis? Is there a simple way we can remove some stuff we don't need to free some up?

@asmeurer
Copy link
Copy Markdown
Member Author

So it looks like Travis has a dynamic disk space limit, which means this issue could disappear and reappear intermittently. We could probably ask them for more space, or figure out how to clear a chunk of the preinstalled stuff that we don't need (is it possible to use language: minimal for only this build?).

But first it would be nice to know if this is even going to work at all. If not we need to stick with the PPA approach, or do something else.

@isuruf
Copy link
Copy Markdown
Member

isuruf commented May 21, 2018

Latest sage package is lighter and works. Now the error is,

+sage -t sympy/external/tests/test_sage.py
no stored timings available
Running doctests with ID 2018-05-21-04-08-36-283cb4e9.
Using --optional=sage
Doctesting 1 file.
sage -t sympy/external/tests/test_sage.py
**********************************************************************
File "sympy/external/tests/test_sage.py", line 270, in sympy.external.tests.test_sage.test_abstract_function
Failed example:
    test_abstract_function()
Exception raised:
    Traceback (most recent call last):
      File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/sage/doctest/forker.py", line 515, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/sage/doctest/forker.py", line 885, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sympy.external.tests.test_sage.test_abstract_function[17]>", line 1, in <module>
        test_abstract_function()
    NameError: name 'test_abstract_function' is not defined
**********************************************************************
1 item had failures:
   1 of  20 in sympy.external.tests.test_sage.test_abstract_function
    [19 tests, 1 failure, 2.81 s]

@asmeurer
Copy link
Copy Markdown
Member Author

My guess is that it's trying to use the SymPy that comes with sage rather than the dev version, although I did try to avoid this scenario by conda removing sympy from the environment. The function in question was added after the last release.

@isuruf
Copy link
Copy Markdown
Member

isuruf commented May 22, 2018

Not sure if this helps. I know that mpmath switches to the sage.Integer backend instead of gmpy2.mpz.

@asmeurer
Copy link
Copy Markdown
Member Author

That is almost certainly the problem thanks.

@asmeurer
Copy link
Copy Markdown
Member Author

The problem is that mpmath's to_rational returns a Sage Integer, which we then pass to the gmpy backend, and it fails. I can fix it, but there are likely other places where this would pop up too. Should we actually be running all the tests with sage installed? I guess this issue would crop up even just using SymPy in sage, assuming sage also includes gmpy2.

@asmeurer
Copy link
Copy Markdown
Member Author

I didn't realize the sage conda-forge packages were available for Mac too. I'll install it and see if I can find any other test failures.

By the way, the llvmlite and theano garbage from the tests are there in master too.

@asmeurer
Copy link
Copy Markdown
Member Author

It doesn't work on my Mac

>>> import sage.all
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/aaronmeurer/anaconda3/envs/python2/lib/python2.7/site-packages/sage/all.py", line 87, in <module>
    from sage.misc.all       import *         # takes a while
  File "/Users/aaronmeurer/anaconda3/envs/python2/lib/python2.7/site-packages/sage/misc/all.py", line 84, in <module>
    from .functional import (additive_order,
  File "/Users/aaronmeurer/anaconda3/envs/python2/lib/python2.7/site-packages/sage/misc/functional.py", line 27, in <module>
    from sage.rings.complex_double import CDF
ImportError: cannot import name CDF

@isuruf
Copy link
Copy Markdown
Member

isuruf commented May 23, 2018

Can you open an issue in https://github.com/conda-forge/sagelib-feedstock?

When Sage is installed, mpmath uses it as a backend. This causes problem when
Sage integers are passed to gmpy functions, which only work with Python ints,
gmpy ints, or strings.
@asmeurer
Copy link
Copy Markdown
Member Author

asmeurer commented May 23, 2018

I got it working on my Mac.

There are a lot of test failures. Some of them are because gmpy's mpq/mpz do not accept Sage Integers, which mpmath uses when Sage is installed. I have pushed a fix that fixes at least some of those issues (I still need to run the full test suite to see if they are all fixed).

There are also some issues where things are giving different answers:

___________________________________________________ sympy/holonomic/tests/test_holonomic.py:test_evalf_rk4 ___________________________________________________
  File "/users/aaronmeurer/documents/python/sympy/sympy/sympy/holonomic/tests/test_holonomic.py", line 407, in test_evalf_rk4
    assert sstr(p.evalf(r)[-1]) == s
AssertionError:
0.909294635227854 + 4.73926453636864e-15*I ==
0.90929463522785 + 1.52655665885959e-16*I

I guess somehow the Sage backend in mpmath has some different rounding.

Some upstream questions:

  • Why does mpmath prefer sage to gmpy when both are installed? Are Sage Integers really faster than gmpy integers? CC @fredrik-johansson
  • Shouldn't mpq work with any input that can be converted to int. According to Argument is not an mpz #12895 (comment), this might be already fixed in a newer version of gmpy2 after 2.0.8 (which hasn't been released yet according to PyPI). CC @casevh

Also, should we try to run the full test suite with Sage installed? I don't want to create four more matrix builds.

@isuruf
Copy link
Copy Markdown
Member

isuruf commented May 23, 2018

Why does mpmath prefer sage to gmpy when both are installed? Are Sage Integers really faster than gmpy integers?

Probably. Both use gmp's mpz type, but sage has a object pool for integers < 10 words if I remember correctly.

@fredrik-johansson
Copy link
Copy Markdown
Contributor

I think gmpy integers are a little faster actually, but what matters is that the Sage backend has mpf/mpc types and a bunch of other code implemented entirely in Cython.

These days it would be better (much faster than either) to write a standalone backend using Arb.

@asmeurer
Copy link
Copy Markdown
Member Author

Looks like the Sage backend to mpmath uses many of its own functions. For instance, we have this test:

    # This looses a binary digit of precision, so it isn't equal to the above,
    # but check that it normalizes correctly
    x2_hex = Float((0, long(0x13333333333333)*2, -53, 53))
    assert x2_hex._mpf_ == (0, 5404319552844595, -52, 52)
    # XXX: Should this test also hold?
    # assert x2_hex._prec == 52

With the Sage backend, it fails (the result is (0, 5404319552844595, -52, 53)), because mpmath's Sage backend uses Sage's normalize function. I wrote this test back when I was fixing issues with Float losing precision (8a7e079). It looks like from the commit message that either value could be considered correct. I guess the other errors are from similar things (there are quite a few mpmath functions that are swapped in with Sage variants).

@asmeurer
Copy link
Copy Markdown
Member Author

Full list of failures:

___________________________________________________ sympy/ntheory/tests/test_partitions.py:test_partitions ___________________________________________________
  File "sympy/utilities/runtests.py", line 1270, in _timeout
    function()
  File "/users/aaronmeurer/documents/python/sympy/sympy/sympy/ntheory/tests/test_partitions.py", line 13, in test_partitions
    assert npartitions(100000) % 10**10 == 9421098519
  File "sympy/ntheory/partitions_.py", line 184, in npartitions
    a = _a(n, q, p)
  File "sympy/ntheory/partitions_.py", line 67, in _a
    from_int(4*m), pi, prec), from_int(mod), prec)
  File "/Users/aaronmeurer/anaconda3/envs/python2/lib/python2.7/site-packages/mpmath/libmp/libmpf.py", line 336, in from_int
    return from_man_exp(n, 0, prec, rnd)
  File "sage/libs/mpmath/utils.pyx", line 82, in sage.libs.mpmath.utils.from_man_exp (build/cythonized/sage/libs/mpmath/utils.c:3778)
  File "sage/libs/mpmath/utils.pyx", line 101, in sage.libs.mpmath.utils.from_man_exp (build/cythonized/sage/libs/mpmath/utils.c:3550)
  File "sage/rings/integer.pyx", line 721, in sage.rings.integer.Integer.__init__ (build/cythonized/sage/rings/integer.c:6698)
TypeError: unable to coerce <type 'mpz'> to an integer
______________________________________________________________________________________________________________________________________________________________
_____________________________________________ sympy/polys/domains/tests/test_domains.py:test_Domain__contains__ ______________________________________________
  File "sympy/utilities/runtests.py", line 1270, in _timeout
    function()
  File "/users/aaronmeurer/documents/python/sympy/sympy/sympy/polys/domains/tests/test_domains.py", line 306, in test_Domain__contains__
    assert (3.0 in ZZ) is True
  File "sympy/polys/domains/domain.py", line 167, in __contains__
    self.convert(a)
  File "sympy/polys/domains/domain.py", line 130, in convert
    return self.convert_from(parent(element), parent)
  File "sympy/polys/domains/domain.py", line 99, in convert_from
    result = _convert(element, base)
  File "sympy/polys/domains/gmpyintegerring.py", line 72, in from_RealField
    return GMPYInteger(p)
TypeError: mpz() requires numeric or string argument

______________________________________________________________________________________________________________________________________________________________
________________________________________________________ sympy/core/tests/test_numbers.py:test_Float _________________________________________________________
  File "sympy/utilities/runtests.py", line 1270, in _timeout
    function()
  File "/users/aaronmeurer/documents/python/sympy/sympy/sympy/core/tests/test_numbers.py", line 415, in test_Float
    assert x2_hex._mpf_ == (0, 5404319552844595, -52, 52)
AssertionError
______________________________________________________________________________________________________________________________________________________________
__________________________________________________ sympy/holonomic/tests/test_holonomic.py:test_evalf_euler __________________________________________________
  File "sympy/utilities/runtests.py", line 1270, in _timeout
    function()
  File "/users/aaronmeurer/documents/python/sympy/sympy/sympy/holonomic/tests/test_holonomic.py", line 325, in test_evalf_euler
    assert sstr(p.evalf(r, method='Euler')[-1]) == s
AssertionError
______________________________________________________________________________________________________________________________________________________________
___________________________________________________ sympy/holonomic/tests/test_holonomic.py:test_evalf_rk4 ___________________________________________________
  File "sympy/utilities/runtests.py", line 1270, in _timeout
    function()
  File "/users/aaronmeurer/documents/python/sympy/sympy/sympy/holonomic/tests/test_holonomic.py", line 407, in test_evalf_rk4
    assert sstr(p.evalf(r)[-1]) == s
AssertionError
______________________________________________________________________________________________________________________________________________________________
______________________________________________________ sympy/polys/tests/test_polyroots.py:test_nroots2 ______________________________________________________
  File "sympy/utilities/runtests.py", line 1270, in _timeout
    function()
  File "/users/aaronmeurer/documents/python/sympy/sympy/sympy/polys/tests/test_polyroots.py", line 661, in test_nroots2
    '1.01 - 0.937*I', '1.01 + 0.937*I']
AssertionError
______________________________________________________________________________________________________________________________________________________________
______________________________________________________ sympy/polys/tests/test_polytools.py:test_nroots _______________________________________________________
  File "sympy/utilities/runtests.py", line 1270, in _timeout
    function()
  File "/users/aaronmeurer/documents/python/sympy/sympy/sympy/polys/tests/test_polytools.py", line 2782, in test_nroots
    assert im(roots[1]).epsilon_eq(-0.86602, eps) is S.false
AssertionError
______________________________________________________________________________________________________________________________________________________________
_________________________________________________ sympy/solvers/tests/test_numeric.py:test_nsolve_precision __________________________________________________
  File "sympy/utilities/runtests.py", line 1270, in _timeout
    function()
  File "/users/aaronmeurer/documents/python/sympy/sympy/sympy/solvers/tests/test_numeric.py", line 93, in test_nsolve_precision
    assert abs(sqrt(pi).evalf(128) - sol) < 1e-128
AssertionError
______________________________________________________________________________________________________________________________________________________________
__________________________________________________ sympy/solvers/tests/test_numeric.py:test_nsolve_complex ___________________________________________________
  File "sympy/utilities/runtests.py", line 1270, in _timeout
    function()
  File "/users/aaronmeurer/documents/python/sympy/sympy/sympy/solvers/tests/test_numeric.py", line 106, in test_nsolve_complex
    assert nsolve(x**2 + 2, 1j) == sqrt(2.)*I
AssertionError
______________________________________________________________________________________________________________________________________________________________
_________________________________________________ sympy/solvers/tests/test_numeric.py:test_nsolve_dict_kwarg _________________________________________________
  File "sympy/utilities/runtests.py", line 1270, in _timeout
    function()
  File "/users/aaronmeurer/documents/python/sympy/sympy/sympy/solvers/tests/test_numeric.py", line 119, in test_nsolve_dict_kwarg
    [{x: sqrt(2.)*I}]
AssertionError

@asmeurer
Copy link
Copy Markdown
Member Author

And doctest failures:

________________________________________________________________ sympy.core.evalf.scaled_zero ________________________________________________________________
File "sympy/core/evalf.py", line 153, in sympy.core.evalf.scaled_zero
Failed example:
    z, p
Exception raised:
    Traceback (most recent call last):
      File "/Users/aaronmeurer/anaconda3/envs/python2/lib/python2.7/doctest.py", line 1315, in __run
        compileflags, 1) in test.globs
      File "<doctest sympy.core.evalf.scaled_zero[3]>", line 1, in <module>
        z, p
      File "sympy/interactive/printing.py", line 30, in _displayhook
        print(stringify_func(arg, **settings))
      File "sympy/printing/str.py", line 866, in sstrrepr
        s = p.doprint(expr)
      File "sympy/printing/printer.py", line 236, in doprint
        return self._str(self._print(expr))
      File "sympy/printing/printer.py", line 274, in _print
        return getattr(self, printmethod)(expr, *args, **kwargs)
      File "sympy/printing/str.py", line 736, in _print_tuple
        return "(%s)" % self.stringify(expr, ", ")
      File "sympy/printing/str.py", line 36, in stringify
        return sep.join([self.parenthesize(item, level) for item in args])
      File "sympy/printing/str.py", line 33, in parenthesize
        return self._print(item)
      File "sympy/printing/printer.py", line 274, in _print
        return getattr(self, printmethod)(expr, *args, **kwargs)
      File "sympy/printing/str.py", line 736, in _print_tuple
        return "(%s)" % self.stringify(expr, ", ")
      File "sympy/printing/str.py", line 36, in stringify
        return sep.join([self.parenthesize(item, level) for item in args])
      File "sympy/printing/str.py", line 30, in parenthesize
        if (precedence(item) < level) or ((not strict) and precedence(item) <= level):
      File "sympy/printing/precedence.py", line 127, in precedence
        return PRECEDENCE_FUNCTIONS[n](item)
      File "sympy/printing/precedence.py", line 70, in precedence_Integer
        if item.p < 0:
      File "sage/structure/element.pyx", line 484, in sage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4413)
      File "sage/structure/element.pyx", line 497, in sage.structure.element.Element.getattr_from_category (build/cythonized/sage/structure/element.c:4522)
      File "sage/cpython/getattr.pyx", line 254, in sage.cpython.getattr.getattr_from_other_class (build/cythonized/sage/cpython/getattr.c:1970)
    AttributeError: 'sage.rings.integer.Integer' object has no attribute 'p'
**********************************************************************
File "sympy/core/evalf.py", line 156, in sympy.core.evalf.scaled_zero
Failed example:
    ok
Exception raised:
    Traceback (most recent call last):
      File "/Users/aaronmeurer/anaconda3/envs/python2/lib/python2.7/doctest.py", line 1315, in __run
        compileflags, 1) in test.globs
      File "<doctest sympy.core.evalf.scaled_zero[5]>", line 1, in <module>
        ok
      File "sympy/interactive/printing.py", line 30, in _displayhook
        print(stringify_func(arg, **settings))
      File "sympy/printing/str.py", line 866, in sstrrepr
        s = p.doprint(expr)
      File "sympy/printing/printer.py", line 236, in doprint
        return self._str(self._print(expr))
      File "sympy/printing/printer.py", line 274, in _print
        return getattr(self, printmethod)(expr, *args, **kwargs)
      File "sympy/printing/str.py", line 736, in _print_tuple
        return "(%s)" % self.stringify(expr, ", ")
      File "sympy/printing/str.py", line 36, in stringify
        return sep.join([self.parenthesize(item, level) for item in args])
      File "sympy/printing/str.py", line 30, in parenthesize
        if (precedence(item) < level) or ((not strict) and precedence(item) <= level):
      File "sympy/printing/precedence.py", line 127, in precedence
        return PRECEDENCE_FUNCTIONS[n](item)
      File "sympy/printing/precedence.py", line 70, in precedence_Integer
        if item.p < 0:
      File "sage/structure/element.pyx", line 484, in sage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4413)
      File "sage/structure/element.pyx", line 497, in sage.structure.element.Element.getattr_from_category (build/cythonized/sage/structure/element.c:4522)
      File "sage/cpython/getattr.pyx", line 254, in sage.cpython.getattr.getattr_from_other_class (build/cythonized/sage/cpython/getattr.c:1970)
    AttributeError: 'sage.rings.integer.Integer' object has no attribute 'p'
______________________________________________________________________________________________________________________________________________________________
_______________________________________________________________ sympy.core.numbers.RealNumber ________________________________________________________________
File "sympy/core/numbers.py", line 934, in sympy.core.numbers.RealNumber
Failed example:
    _._mpf_
Exception raised:
    Traceback (most recent call last):
      File "/Users/aaronmeurer/anaconda3/envs/python2/lib/python2.7/doctest.py", line 1315, in __run
        compileflags, 1) in test.globs
      File "<doctest sympy.core.numbers.RealNumber[32]>", line 1, in <module>
        _._mpf_
      File "sympy/interactive/printing.py", line 30, in _displayhook
        print(stringify_func(arg, **settings))
      File "sympy/printing/str.py", line 866, in sstrrepr
        s = p.doprint(expr)
      File "sympy/printing/printer.py", line 236, in doprint
        return self._str(self._print(expr))
      File "sympy/printing/printer.py", line 274, in _print
        return getattr(self, printmethod)(expr, *args, **kwargs)
      File "sympy/printing/str.py", line 736, in _print_tuple
        return "(%s)" % self.stringify(expr, ", ")
      File "sympy/printing/str.py", line 36, in stringify
        return sep.join([self.parenthesize(item, level) for item in args])
      File "sympy/printing/str.py", line 30, in parenthesize
        if (precedence(item) < level) or ((not strict) and precedence(item) <= level):
      File "sympy/printing/precedence.py", line 127, in precedence
        return PRECEDENCE_FUNCTIONS[n](item)
      File "sympy/printing/precedence.py", line 70, in precedence_Integer
        if item.p < 0:
      File "sage/structure/element.pyx", line 484, in sage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4413)
      File "sage/structure/element.pyx", line 497, in sage.structure.element.Element.getattr_from_category (build/cythonized/sage/structure/element.c:4522)
      File "sage/cpython/getattr.pyx", line 254, in sage.cpython.getattr.getattr_from_other_class (build/cythonized/sage/cpython/getattr.c:1970)
    AttributeError: 'sage.rings.integer.Integer' object has no attribute 'p'
______________________________________________________________________________________________________________________________________________________________
________________________________________________________________ sympy.polys.polytools.nroots ________________________________________________________________
File "sympy/polys/polytools.py", line 6480, in sympy.polys.polytools.nroots
Failed example:
    nroots(x**2 - 3, n=30)
Expected:
    [-1.73205080756887729352744634151, 1.73205080756887729352744634151]
Got:
    [-1.73205080756888, 1.73205080756888]
______________________________________________________________________________________________________________________________________________________________
_____________________________________________________________ sympy.polys.polytools.Poly.nroots ______________________________________________________________
File "sympy/polys/polytools.py", line 3553, in sympy.polys.polytools.Poly.nroots
Failed example:
    Poly(x**2 - 3).nroots(n=30)
Expected:
    [-1.73205080756887729352744634151, 1.73205080756887729352744634151]
Got:
    [-1.73205080756888, 1.73205080756888]
______________________________________________________________________________________________________________________________________________________________
________________________________________________________________ sympy.solvers.solvers.nsolve ________________________________________________________________
File "sympy/solvers/solvers.py", line 2810, in sympy.solvers.solvers.nsolve
Failed example:
    nsolve(x**2 + 2, I)
Expected:
    1.4142135623731*I
Got:
    -5.12588859584049e-25 + 1.4142135623731*I
______________________________________________________________________________________________________________________________________________________________
________________________________________________________________ sympy.solvers.solvers.solve _________________________________________________________________
File "sympy/solvers/solvers.py", line 894, in sympy.solvers.solvers.solve
Failed example:
    [xi.n(chop=1e-9) for xi in xvals if abs(z1.subs(x, xi).n()) < 1e-9]
Expected:
    [-3.0]
Got:
    []

@asmeurer
Copy link
Copy Markdown
Member Author

By the way, it looks like Sage does some funny stuff when it is imported (it adds a signal handler for Ctrl-C, don't know what else it does). It's probably a good idea to install it only in a separate conda environment for local development.

@asmeurer
Copy link
Copy Markdown
Member Author

Sage's mpf type doesn't subclass from mpmath's mpnumeric, which makes it so that sympify doesn't convert sage mpf objects correctly.

I'm unsure which of these issues we should try to work around and which should just be considered upstream sage, mpmath, and/or gmpy issues.

Mpmath using the Sage backend causes issues throughout SymPy, which are
generally bugs with upstream Sage, mpmath, and/or gmpy2 (see sympy#14703). Also we
would really need to be running the full test suite with Sage installed to be
catching all of these (TEST_OPT_DEPENDENCY where the Sage tests are run only
runs a subset of the test suite).
@asmeurer
Copy link
Copy Markdown
Member Author

Also part of me just wants to set MPMATH_NOSAGE after the sage tests are run and let the Sage guys deal with the upstream issues on their own.

@casevh
Copy link
Copy Markdown
Contributor

casevh commented May 24, 2018 via email

@asmeurer
Copy link
Copy Markdown
Member Author

With 2.1.0a2 I get the same issue:

>>> gmpy2.mpq(sage.all.Integer(2), sage.all.Integer(3))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: mpq() requires numeric or string argument
>>> gmpy2.version()
'2.1.0a2'

asmeurer added 3 commits May 24, 2018 16:30
Python 2 doesn't show chained exceptions, so this is needed to see the real
error on Travis.
@asmeurer
Copy link
Copy Markdown
Member Author

asmeurer commented May 25, 2018

I've fixed this by making it so that mpmath only uses the sage backend for the sage tests. If someone wants to try to fix (workaround) the upstream issues that are caused when it is used for the full test suite, go ahead. But as far as I'm concerned, this PR is ready to go.

@Abdullahjavednesar Abdullahjavednesar added PR: sympy's turn and removed PR: author's turn The PR has been reviewed and the author needs to submit more changes. labels May 25, 2018
@asmeurer
Copy link
Copy Markdown
Member Author

Upstream Sage issue https://trac.sagemath.org/ticket/25445

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix TEST_SAGE=yes Travis script

5 participants