def _test(chat=None):
    if chat:
        print("Unit tests for gmpy 1.15 (threading)")
        print("    running on Python", sys.version)
        print()
        if _g.gmp_version():
            print("Testing gmpy %s (GMP %s) with default caching (%s, %s)" % (
                (_g.version(), _g.gmp_version(), _g.get_cache()[0],
                _g.get_cache()[1])))
        else:
            print("Testing gmpy %s (MPIR %s) with default caching (%s, %s)" % (
                (_g.version(), _g.mpir_version(), _g.get_cache()[0],
                _g.get_cache()[1])))

    thismod = sys.modules.get(__name__)
    doctest.testmod(thismod, report=0)

    if chat: print("Repeating tests, with caching disabled")
    _g.set_cache(0,128)

    sav = sys.stdout
    class _Dummy:
        def write(self,*whatever):
            pass
    try:
        sys.stdout = _Dummy()
        doctest.testmod(thismod, report=0)
    finally:
        sys.stdout = sav

    if chat:
        print()
        print("Overall results for thr:")
    return doctest.master.summarize(chat)
def _test(chat=None):
    if chat:
        print("Unit tests for gmpy 1.15 (mpz functionality)")
        print("    running on Python %s" % sys.version)
        print()
        if _g.gmp_version():
            print("Testing gmpy %s (GMP %s), default caching (%s, %s)" % (
                (_g.version(), _g.gmp_version(), _g.get_cache()[0],
                _g.get_cache()[1])))
        else:
            print("Testing gmpy %s (MPIR %s), default caching (%s, %s)" % (
                (_g.version(), _g.mpir_version(), _g.get_cache()[0],
                _g.get_cache()[1])))
    thismod = sys.modules.get(__name__)
    doctest.testmod(thismod, report=0)

    if chat: print("Repeating tests, with caching disabled")
    _g.set_cache(0,128)

    sav = sys.stdout
    class _Dummy:
        encoding = None
        def write(self,*whatever):
            pass
    try:
        sys.stdout = _Dummy()
        doctest.testmod(thismod, report=0)
    finally:
        sys.stdout = sav

    if chat:
        print()
        print("Overall results for mpz:")
    return doctest.master.summarize(chat)
Example #3
0
def _test(chat=None):
    python_version = sys.version_info[:3]
    if python_version == (2, 4, 0):
        print "You're using Python 2.4.0, which does not allow interoperability"
        print "  between decimal and other types (due to a bug fixed in 2.4.1)"
        print "  No point in testing, therefore -- please upgrade your Python!"
        return 0, 0
    if chat:
        print "Unit tests for gmpy 1.17 (decimal interoperation)"
        print "    running on Python", sys.version
        print
        if _g.gmp_version():
            print "Testing gmpy %s (GMP %s) with default caching (%s, %s)" % (
                (_g.version(), _g.gmp_version(), _g.get_cache()[0],
                _g.get_cache()[1]))
        else:
            print "Testing gmpy %s (MPIR %s) with default caching (%s, %s)" % (
                (_g.version(), _g.mpir_version(), _g.get_cache()[0],
                _g.get_cache()[1]))

    if not _d:
        if chat:
            print "Can't test, since can't import decimal"
        return 0, 0
    thismod = sys.modules.get(__name__)
    doctest.testmod(thismod, report=0)

    if chat:
        print
        print "Overall results for dec:"
    return doctest.master.summarize(chat)
Example #4
0
def print_version(is_server):
    from mathics.optional import sage_version
    import sympy
    import mpmath
    import gmpy
    try:
        import django
        from django.conf import settings
        version = settings.VERSION
        django_version = django.get_version()        
    except ImportError:
        from mathics import settings
        version = settings.VERSION
        django_version = None
    
    print u"\nMathics %s" % settings.VERSION
    #print u"Copyright (c) 2009-2010 by Jan Pöschko"
    if sage_version is not None:
        print u"on %s" % sage_version
    libs = []
    if django_version is not None and is_server:
        libs.append("Django %s" % django_version)
    libs += ["SymPy %s" % sympy.__version__, "mpmath %s" % mpmath.__version__,
        "GMPY %s" % gmpy.version()]
    print u"using %s" % ", ".join(libs)
def _test(chat=None):
    if chat:
        print "Unit tests for gmpy 1.15 (extra cover)"
        print "    running on Python", sys.version
        print
        if _g.gmp_version():
            print "Testing gmpy %s (GMP %s) with default caching (%s, %s)" % (
                (_g.version(), _g.gmp_version(), _g.get_cache()[0],
                _g.get_cache()[1]))
        else:
            print "Testing gmpy %s (MPIR %s) with default caching (%s, %s)" % (
                (_g.version(), _g.mpir_version(), _g.get_cache()[0],
                _g.get_cache()[1]))

    thismod = sys.modules.get(__name__)
    doctest.testmod(thismod, report=0)

    if chat:
        print
        print "Overall results for cvr:"
    return doctest.master.summarize(chat)
Example #6
0
def pytest_report_header(config):
    s = "architecture: %s\n" % ARCH
    s += "cache:        %s\n" % USE_CACHE
    version = ''
    if GROUND_TYPES == 'gmpy':
        if HAS_GMPY == 1:
            import gmpy
        elif HAS_GMPY == 2:
            import gmpy2 as gmpy
        version = gmpy.version()
    s += "ground types: %s %s\n" % (GROUND_TYPES, version)
    return s
Example #7
0
def _test(chat=None):
    if chat:
        print "Unit tests for gmpy 1.15 (extra cover)"
        print "    running on Python", sys.version
        print
        if _g.gmp_version():
            print "Testing gmpy %s (GMP %s) with default caching (%s, %s)" % (
                (_g.version(), _g.gmp_version(), _g.get_cache()[0],
                 _g.get_cache()[1]))
        else:
            print "Testing gmpy %s (MPIR %s) with default caching (%s, %s)" % (
                (_g.version(), _g.mpir_version(), _g.get_cache()[0],
                 _g.get_cache()[1]))

    thismod = sys.modules.get(__name__)
    doctest.testmod(thismod, report=0)

    if chat:
        print
        print "Overall results for cvr:"
    return doctest.master.summarize(chat)
Example #8
0
def _test(chat=None):
    if chat:
        print("Unit tests for gmpy 1.17 (rand functionality)")
        print("    running on Python %s" % sys.version)
        print("")
        if _g.gmp_version():
            print("Testing gmpy %s (GMP %s) with default caching (%s, %s)" % (
                (_g.version(), _g.gmp_version(), _g.get_cache()[0],
                _g.get_cache()[1])))
        else:
            print("Testing gmpy %s (MPIR %s) with default caching (%s, %s)" % (
                (_g.version(), _g.mpir_version(), _g.get_cache()[0],
                _g.get_cache()[1])))

    thismod = sys.modules.get(__name__)
    doctest.testmod(thismod, report=0)

    if chat:
        print("")
        print("Overall results for rnd:")
    return doctest.master.summarize(chat)
def _test(chat=None):
    if chat:
        print("Unit tests for gmpy 1.15 (rand functionality)")
        print("    running on Python %s" % sys.version)
        print("")
        if _g.gmp_version():
            print("Testing gmpy %s (GMP %s) with default caching (%s, %s)" % (
                (_g.version(), _g.gmp_version(), _g.get_cache()[0],
                _g.get_cache()[1])))
        else:
            print("Testing gmpy %s (MPIR %s) with default caching (%s, %s)" % (
                (_g.version(), _g.mpir_version(), _g.get_cache()[0],
                _g.get_cache()[1])))

    thismod = sys.modules.get(__name__)
    doctest.testmod(thismod, report=0)

    if chat:
        print("")
        print("Overall results for rnd:")
    return doctest.master.summarize(chat)
def _test(chat=None):
    try:
        float('nan')
    except ValueError:
        if "special" in __test__:
            del(__test__["special"])

    if chat:
        print "Unit tests for gmpy 1.15 (mpz functionality)"
        print "    running on Python %s" % sys.version
        print
        if _g.gmp_version():
            print "Testing gmpy %s (GMP %s) with default caching (%s, %s)" % (
                (_g.version(), _g.gmp_version(), _g.get_cache()[0],
                _g.get_cache()[1]))
        else:
            print "Testing gmpy %s (MPIR %s) with default caching (%s, %s)" % (
                (_g.version(), _g.mpir_version(), _g.get_cache()[0],
                _g.get_cache()[1]))

    thismod = sys.modules.get(__name__)
    doctest.testmod(thismod, report=0)

    if chat: print "Repeating tests, with caching disabled"
    _g.set_cache(0,128)

    sav = sys.stdout
    class _Dummy:
        def write(self,*whatever):
            pass
    try:
        sys.stdout = _Dummy()
        doctest.testmod(thismod, report=0)
    finally:
        sys.stdout = sav

    if chat:
        print
        print "Overall results for mpz:"
    return doctest.master.summarize(chat)
Example #11
0
def pytest_report_header(config):
    from sympy.utilities.misc import ARCH
    s = "architecture: %s\n" % ARCH
    from sympy.core.cache import USE_CACHE
    s += "cache:        %s\n" % USE_CACHE
    from sympy.external.gmpy import GROUND_TYPES, HAS_GMPY
    version = ''
    if GROUND_TYPES == 'gmpy':
        if HAS_GMPY == 1:
            import gmpy
        elif HAS_GMPY == 2:
            import gmpy2 as gmpy
        version = gmpy.version()
    s += "ground types: %s %s\n" % (GROUND_TYPES, version)
    return s
Example #12
0
def pytest_report_header(config):
    from sympy.utilities.misc import ARCH
    s = "architecture: %s\n" % ARCH
    from sympy.core.cache import USE_CACHE
    s += "cache:        %s\n" % USE_CACHE
    from sympy.core.compatibility import GROUND_TYPES, HAS_GMPY
    version = ''
    if GROUND_TYPES =='gmpy':
        if HAS_GMPY == 1:
            import gmpy
        elif HAS_GMPY == 2:
            import gmpy2 as gmpy
        version = gmpy.version()
    s += "ground types: %s %s\n" % (GROUND_TYPES, version)
    return s
Example #13
0
def _test(chat=None):
    if chat:
        print "Unit tests for gmpy 1.15 (threading)"
        print "    running on Python", sys.version
        print
        if _g.gmp_version():
            print "Testing gmpy %s (GMP %s) with default caching (%s, %s)" % (
                (_g.version(), _g.gmp_version(), _g.get_cache()[0],
                 _g.get_cache()[1]))
        else:
            print "Testing gmpy %s (MPIR %s) with default caching (%s, %s)" % (
                (_g.version(), _g.mpir_version(), _g.get_cache()[0],
                 _g.get_cache()[1]))

    thismod = sys.modules.get(__name__)
    doctest.testmod(thismod, report=0)

    if chat: print "Repeating tests, with caching disabled"
    _g.set_zcache(0)

    sav = sys.stdout

    class _Dummy:
        def write(self, *whatever):
            pass

    try:
        sys.stdout = _Dummy()
        doctest.testmod(thismod, report=0)
    finally:
        sys.stdout = sav

    if chat:
        print
        print "Overall results for thr:"
    return doctest.master.summarize(chat)
Example #14
0
def get_version():
    version = {}
    
    from mathics.optional import sage_version
    import sympy
    import mpmath
    import gmpy
    try:
        import django
        from django.conf import settings
        version['mathics'] = settings.VERSION
        version['django'] = django.get_version()        
    except ImportError:
        from mathics import settings
        version['mathics'] = settings.VERSION
    if sage_version is not None:
        version['sage'] = sage_version
    version['sympy'] = sympy.__version__
    version['mpmath'] = mpmath.__version__
    version['gmpy'] = gmpy.version()
    return version
Example #15
0
# Side-effects                                                               #
# 1) "is" cannot be used to test for special values. Must use "==".          #
# 2) There are bugs in GMPY prior to v1.02 so we must use v1.03 or later.    #
#----------------------------------------------------------------------------#

# So we can import it from this module
gmpy = None
sage = None

MODE = 'python'
MP_BASE = long

if 'MPMATH_NOGMPY' not in os.environ:
    try:
        import gmpy
        if gmpy.version() >= '1.03':
            MODE = 'gmpy'
            MP_BASE = gmpy.mpz
    except:
        pass

if 'MPMATH_NOSAGE' not in os.environ:
    try:
        import sage.all
        if hasattr(sage.all.Integer, "trailing_zero_bits"):
            sage = sage.all
            MODE = 'sage'
            MP_BASE = sage.Integer
    except:
        pass
Example #16
0
# Side-effects                                                               #
# 1) "is" cannot be used to test for special values. Must use "==".          #
# 2) There are bugs in GMPY prior to v1.02 so we must use v1.03 or later.    #
#----------------------------------------------------------------------------#

# So we can import it from this module
gmpy = None
sage = None

MODE = 'python'
MP_BASE = long

if 'MPMATH_NOGMPY' not in os.environ:
    try:
        import gmpy
        if gmpy.version() >= '1.03':
            MODE = 'gmpy'
            MP_BASE = gmpy.mpz
    except:
        pass

if 'MPMATH_NOSAGE' not in os.environ:
    try:
        import sage.all
        if hasattr(sage.all.Integer, "trailing_zero_bits"):
            sage = sage.all
            MODE = 'sage'
            MP_BASE = sage.Integer
    except:
        pass
Example #17
0
#                                                                            #
# Side-effects                                                               #
# 1) "is" cannot be used to test for special values. Must use "==".          #
# 2) There are bugs in GMPY prior to v1.02 so we must use v1.03 or later.    #
# ----------------------------------------------------------------------------#

# So we can import it from this module
gmpy = None

MODE = "python"
MP_BASE = long
if "MPMATH_NOGMPY" not in os.environ:
    try:
        import gmpy

        if gmpy.version() >= "1.03":
            MODE = "gmpy"
            MP_BASE = gmpy.mpz
    except:
        pass

if os.environ.has_key("MPMATH_STRICT"):
    STRICT = True
else:
    STRICT = False

MP_BASE_TYPE = type(MP_BASE(0))
MP_ZERO = MP_BASE(0)
MP_ONE = MP_BASE(1)
MP_TWO = MP_BASE(2)
MP_THREE = MP_BASE(3)