Python sympy.__version__() Examples

The following are 4 code examples of sympy.__version__(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module sympy , or try the search function .
Example #1
Source File: test_sympy_conv.py    From symengine.py with MIT License 5 votes vote down vote up
def test_pynumber():
    a = sympy.FF(7)(3)
    b = sympify(a)

    assert isinstance(b, PyNumber)

    a = a + 1
    b = b + 1
    assert isinstance(b, PyNumber)
    assert b == a                  # Check equality via SymEngine
    assert a == b                  # Check equality via SymPy

    a = 1 - a
    b = 1 - b
    assert isinstance(b, PyNumber)
    assert b == a                  # Check equality via SymEngine
    assert a == b                  # Check equality via SymPy

    a = 2 * a
    b = 2 * b
    assert isinstance(b, PyNumber)
    assert b == a                  # Check equality via SymEngine
    assert a == b                  # Check equality via SymPy

    if sympy.__version__ != '1.2':
        a = 2 / a
        b = 2 / b
        assert isinstance(b, PyNumber)
        assert b == a                  # Check equality via SymEngine
        assert a == b                  # Check equality via SymPy

    x = Symbol("x")
    b = x * sympy.FF(7)(3)
    assert isinstance(b, Mul)

    b = b / x
    assert isinstance(b, PyNumber) 
Example #2
Source File: symbolic.py    From simupy with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def lambdify_with_vector_args(args, expr, modules=DEFAULT_LAMBDIFY_MODULES):
    """
    A wrapper around sympy's lambdify where process_vector_args is used so
    generated callable can take arguments as either vector or individual
    components

    Parameters
    ----------
    args : list-like of sympy symbols
        Input arguments to the expression to call
    expr : sympy expression
        Expression to turn into a callable for numeric evaluation
    modules : list
        See lambdify documentation; passed directly as modules keyword.

    """
    new_args = process_vector_args(args)

    if sp.__version__ < '1.1' and hasattr(expr, '__len__'):
        expr = sp.Matrix(expr)

    f = sp.lambdify(new_args, expr, modules=modules)

    def lambda_function_with_vector_args(*func_args):
        new_func_args = process_vector_args(func_args)
        return np.array(f(*new_func_args))
    lambda_function_with_vector_args.__doc__ = f.__doc__
    return lambda_function_with_vector_args 
Example #3
Source File: __init__.py    From strawberryfields with Apache License 2.0 4 votes vote down vote up
def about():
    """Strawberry Fields information.

    Prints the installed version numbers for SF and its dependencies,
    and some system info. Please include this information in bug reports.

    **Example:**

    .. code-block:: pycon

        >>> sf.about()
        Strawberry Fields: a Python library for continuous-variable quantum circuits.
        Copyright 2018-2020 Xanadu Quantum Technologies Inc.

        Python version:            3.6.8
        Platform info:             Linux-5.0.0-36-generic-x86_64-with-debian-buster-sid
        Installation path:         /home/josh/Dropbox/Work/Xanadu/sf_cloud/strawberryfields
        Strawberry Fields version: 0.12.0-dev
        Numpy version:             1.17.4
        Scipy version:             1.3.0
        Sympy version:             1.5
        NetworkX version:          2.4
        The Walrus version:        0.10.0
        Blackbird version:         0.2.1
        TensorFlow version:        2.0.0
    """
    # pylint: disable=import-outside-toplevel
    import sys
    import platform
    import os
    import numpy
    import scipy
    import sympy
    import networkx
    import thewalrus
    import blackbird

    # a QuTiP-style infobox
    print("\nStrawberry Fields: a Python library for continuous-variable quantum circuits.")
    print("Copyright 2018-2020 Xanadu Quantum Technologies Inc.\n")

    print("Python version:            {}.{}.{}".format(*sys.version_info[0:3]))
    print("Platform info:             {}".format(platform.platform()))
    print("Installation path:         {}".format(os.path.dirname(__file__)))
    print("Strawberry Fields version: {}".format(__version__))
    print("Numpy version:             {}".format(numpy.__version__))
    print("Scipy version:             {}".format(scipy.__version__))
    print("SymPy version:             {}".format(sympy.__version__))
    print("NetworkX version:          {}".format(networkx.__version__))
    print("The Walrus version:        {}".format(thewalrus.__version__))
    print("Blackbird version:         {}".format(blackbird.__version__))

    try:
        import tensorflow

        tf_version = tensorflow.__version__
    except ImportError:
        tf_version = None

    print("TensorFlow version:        {}".format(tf_version)) 
Example #4
Source File: setup.py    From phoebe2 with GNU General Public License v3.0 4 votes vote down vote up
def run(self):
    required, optional = [], []
    try:
      import astropy
      astropy_version = astropy.__version__
      if LooseVersion(astropy_version) < LooseVersion('1.0'):
        required.append('astropy 1.0+')
    except:
      required.append('astropy')
    try:
      import scipy
      scipy_version = scipy.__version__
      if LooseVersion(scipy_version) < LooseVersion('0.1'):
        required.append('scipy 0.1+')
    except:
      required.append('scipy')
    try:
      import matplotlib
      mpl_version = matplotlib.__version__
      if LooseVersion(mpl_version) < LooseVersion('1.4.3'):
        optional.append('matplotlib 1.4.3+')
    except:
      optional.append('matplotlib')
    try:
      import sympy
      sympy_version = sympy.__version__
      if LooseVersion(sympy_version) < LooseVersion('1.0'):
        optional.append('sympy 1.0+')
    except:
      optional.append('sympy')

    if required == []:
      print('All required import dependencies satisfied.')
    else:
      print('NOTE: while all the build dependencies are satisfied, the following import dependencies')
      print('      are still missing: %s.' % required)
      print('      You will not be able to import phoebe before you install those dependencies.')

    if optional == []:
      print('All optional import dependencies satisfied.')
    else:
      print('NOTE: while all the build dependencies are satisfied, the following optional dependencies')
      print('      are still missing: %s.' % optional)
      print('      Some of the core phoebe functionality will be missing until you install those dependencies.')