Ejemplo n.º 1
0
def test_xreplace():
    assert b21.xreplace({b2: b1}) == Basic(b1, b1)
    assert b21.xreplace({b2: b21}) == Basic(b21, b1)
    assert b3.xreplace({b2: b1}) == b2
    assert Basic(b1, b2).xreplace({b1: b2, b2: b1}) == Basic(b2, b1)
    assert Atom(b1).xreplace({b1: b2}) == Atom(b1)
    assert Atom(b1).xreplace({Atom(b1): b2}) == b2
    raises(TypeError, 'b1.xreplace()')
    raises(TypeError, 'b1.xreplace([b1,b2])')
Ejemplo n.º 2
0
def test_xreplace():
    assert b21.xreplace({b2: b1}) == Basic(b1, b1)
    assert b21.xreplace({b2: b21}) == Basic(b21, b1)
    assert b3.xreplace({b2: b1}) == b2
    assert Basic(b1, b2).xreplace({b1: b2, b2: b1}) == Basic(b2, b1)
    assert Atom(b1).xreplace({b1: b2}) == Atom(b1)
    assert Atom(b1).xreplace({Atom(b1): b2}) == b2
    raises(TypeError, lambda: b1.xreplace())
    raises(TypeError, lambda: b1.xreplace([b1, b2]))
    for f in (exp, Function('f')):
        assert f.xreplace({}) == f
        assert f.xreplace({}, hack2=True) == f
        assert f.xreplace({f: b1}) == b1
        assert f.xreplace({f: b1}, hack2=True) == b1
Ejemplo n.º 3
0
def test_core_basic():
    for c in (Atom, Atom(),
              Basic, Basic(),
              # XXX: dynamically created types are not picklable
              # BasicMeta, BasicMeta("test", (), {}),
              SingletonRegistry, S):
        check(c)
Ejemplo n.º 4
0
    def __new__(cls, cartantype):
        """Create a new RootSystem object

        This method assigns an attribute called cartan_type to each instance of
        a RootSystem object.  When an instance of RootSystem is called, it
        needs an argument, which should be an instance of a simple Lie algebra.
        We then take the CartanType of this argument and set it as the
        cartan_type attribute of the RootSystem instance.

        """
        obj = Atom.__new__(cls)
        obj.cartan_type = CartanType(cartantype)
        return obj
Ejemplo n.º 5
0
def test_sympy__core__basic__Atom():
    from sympy.core.basic import Atom
    assert _test_args(Atom())
Ejemplo n.º 6
0
def test_core_basic():
    for c in (Atom, Atom(), Basic, Basic(), BasicMeta,
              BasicMeta("test"), BasicType, BasicType("test"), ClassRegistry,
              ClassRegistry(), SingletonRegistry, SingletonRegistry()):
        check(c)
Ejemplo n.º 7
0
 def __new__(cls, cartantype):
     obj = Atom.__new__(cls)
     obj.cartan_type = CartanType(cartantype)
     return obj
Ejemplo n.º 8
0
 def __new__(cls, function):
     if not callable(function):
         raise TypeError('Callable expected, got: %r' % function)
     obj = Atom.__new__(cls)
     obj.function = function
     return obj