File:  [CENS] / python / pyGiNaC / test4 / test_mul.py
Revision 1.2: download - view: text, annotated - select for diffs - revision graph
Mon Nov 26 22:37:44 2001 UTC (15 years, 11 months ago) by pearu
Branches: MAIN
CVS tags: HEAD
See NEWS.txt (impl. matrix)

#!/usr/bin/env python
"""
  test_mul - run ginac.mul tests.
  Usage:
    python test_mul.py [-v]
"""
"""
  This file is part of the PyGiNaC package.
  http://cens.ioc.ee/projects/pyginac/

  $Revision: 1.2 $
  $Id: test_mul.py,v 1.2 2001-11-26 22:37:44 pearu Exp $
 
  Copyright 2001 Pearu Peterson all rights reserved,
  Pearu Peterson <pearu@cens.ioc.ee>
  Permission to use, modify, and distribute this software is given under the
  terms of the LGPL.  See http://www.fsf.org
 
  NO WARRANTY IS EXPRESSED OR IMPLIED.  USE AT YOUR OWN RISK.
"""

import test_all
import ginac

class test_mul(ginac.mul):
    """
    >>> test_save (p=-symbol ('a')*2,q=symbol ('b')*symbol ('a'))
    """
    def __init__(self):
        """
        >>> mul()
        numeric('1')
        >>> mul(2,symbol('a'))
        mul(symbol('a'),numeric('2'))
        """
    def get_precedence(self):
        """
        >>> mul(2,symbol('a')).get_precedence()
        50
        """
    def get_class_name(self):
        """
        >>> mul(2,symbol('a')).get_class_name()
        'mul'
        """
    def __repr__(self):
        """See __init__."""
    def __str__(self):
        """
        >>> mul(-2,symbol('a')).__str__ ()
        '-2*a'
        >>> mul(-1,symbol('a')).__str__()
        '-a'
        >>> mul(2,symbol('a')).__str__()
        '2*a'
        >>> mul(symbol('b'),symbol('a')).__str__()
        'b*a'
        >>> mul(symbol('a'),symbol('a'),2).__str__()
        '2*a**2'
        >>> mul(symbol('a'),symbol('a'),symbol('b')).__str__()
        'b*a**2'
        """
    def extract_archived(self):
        """
        >>> mul(2,symbol('a')).extract_archived()
        {'rest': [{'class': 'symbol', 'name': 'a'}], 'class': 'mul', 'overall_coeff': {'number': '2', 'class': 'numeric'}, 'coeff': [{'number': '1', 'class': 'numeric'}]}
        """
    def to_context(self):
        """
        >>> mul(2,symbol('a')).to_context()
        '2*a'
        >>> mul(2,symbol('a')).to_context('latex')
        '2 a'
        >>> mul(2,symbol('a')).to_context('csrc')
        '2.000000e+00*a'
        """
    def nops(self):
        """
        >>> mul(2,symbol('a')).nops()
        2
        """
    def op(self):
        """
        >>> mul(2,symbol('a')).op(0)
        symbol('a')
        >>> mul(2,symbol('a')).op(1)
        numeric('2')
        """
    def __abs__ (self):
        """
        >>> abs (p)
        mul(abs(symbol('a')),numeric('2'))
        """
    def __add__ (self):
        """
        >>> p+1
        add(mul(symbol('a'),numeric('-2')),numeric('1'))
        """
    def __radd__ (self):
        """
        >>> 1+p
        add(mul(symbol('a'),numeric('-2')),numeric('1'))
        """
    def __sub__ (self):
        """
        >>> p-1
        add(mul(symbol('a'),numeric('-2')),numeric('-1'))
        """
    def __rsub__ (self):
        """
        >>> 1-p
        add(mul(symbol('a'),numeric('2')),numeric('1'))
        """
    def __mul__ (self):
        """
        >>> p*2
        mul(symbol('a'),numeric('-4'))
        """
    def __rmul__ (self):
        """
        >>> 2*p
        mul(symbol('a'),numeric('-4'))
        """
    def __div__ (self):
        """
        >>> p/3
        mul(symbol('a'),numeric('-2/3'))
        """
    def __rdiv__ (self):
        """
        >>> 3/p
        mul(power(symbol('a'),numeric('-1')),numeric('-3/2'))
        """
    def __pos__ (self):
        """
        >>> +p
        mul(symbol('a'),numeric('-2'))
        """
    def __neg__ (self):
        """
        >>> -p
        mul(symbol('a'),numeric('2'))
        """
    def __pow__ (self):
        """
        >>> p**2
        mul(power(symbol('a'),numeric('2')),numeric('4'))
        """
    def __rpow__ (self):
        """
        >>> 2**p
        power(numeric('2'),mul(symbol('a'),numeric('-2')))
        """
    def __coerce__ (self):
        """
        >>> coerce (p,1)
        (mul(symbol('a'),numeric('-2')), numeric('1'))
        """
    def __nonzero__ (self):
        """
        >>> not p
        0
        """
    def eval (self):
        """
        >>> p.eval ()
        mul(symbol('a'),numeric('-2'))
        """
    def evalm (self):
        """
        >>> p.evalm ()
        mul(symbol('a'),numeric('-2'))
        """
    def evalf (self):
        """
        >>> p.evalf ()
        mul(symbol('a'),numeric('-2.0'))
        """
    def numer (self):
        """
        >>> p.numer ()
        mul(symbol('a'),numeric('-2'))
        """
    def denom (self):
        """
        >>> p.denom ()
        numeric('1')
        """
    def numer_denom (self):
        """
        >>> p.numer_denom ()
        (mul(symbol('a'),numeric('-2')), numeric('1'))
        >>> (p/3).numer_denom ()
        (mul(symbol('a'),numeric('-2')), numeric('3'))
        """
    def to_list (self):
        """
        >>> p.to_list ()
        [symbol('a'), numeric('-2')]
        """
    def is_equal (self):
        """
        >>> p.is_equal (p)
        1
        >>> p.is_equal (-2*symbol ('a'))
        1
        >>> p.is_equal (2*p)
        0
        >>> p.is_equal (1)
        0
        """
    def is_zero (self):
        """
        >>> p.is_zero ()
        0
        """
    def has (self):
        """
        >>> p.has (symbol ('a'))
        1
        >>> p.has (p)
        1
        >>> p.has (2*p)
        0
        >>> p.has (-2*symbol ('a'))
        1
        >>> p.has (1)
        0
        >>> p.has (-2)
        1
        """
    def swap (self):
        """
        >>> p.swap (q)
        >>> p,q
        (mul(symbol('b'),symbol('a')), mul(symbol('a'),numeric('-2')))
        >>> p.swap (q)
        >>> p,q
        (mul(symbol('a'),numeric('-2')), mul(symbol('b'),symbol('a')))
        """
    def __eq__ (self):
        """
        >>> p==2
        relational(mul(symbol('a'),numeric('-2')),numeric('2'),'==')
        """
    def __ne__ (self):
        """
        >>> p!=2
        relational(mul(symbol('a'),numeric('-2')),numeric('2'),'!=')
        """
    def __lt__ (self):
        """
        >>> p<2
        relational(mul(symbol('a'),numeric('-2')),numeric('2'),'<')
        """
    def __le__ (self):
        """
        >>> p<=2
        relational(mul(symbol('a'),numeric('-2')),numeric('2'),'<=')
        """
    def __gt__ (self):
        """
        >>> p>2
        relational(numeric('2'),mul(symbol('a'),numeric('-2')),'<')
        """
    def __ge__ (self):
        """
        >>> p>=2
        relational(numeric('2'),mul(symbol('a'),numeric('-2')),'<=')
        """
    def get_hash (self):
        """
        >>> type ( p.get_hash () ) is type (0)
        1
        """
    def diff (self):
        """
        >>> p.diff (symbol ('a'))
        numeric('-2')
        >>> (p*q).diff (symbol ('a'),2)
        mul(symbol('b'),numeric('-4'))
        """
    def integer_content (self):
        """
        >>> p.integer_content ()
        numeric('2')
        >>> q.integer_content ()
        numeric('1')
        """
    def max_coefficient (self):
        """
        >>> p.max_coefficient ()
        numeric('2')
        >>> q.max_coefficient ()
        numeric('1')
        """
    def unit (self):
        """
        >>> p.unit (symbol ('a'))
        numeric('-1')
        >>> q.unit (symbol ('a'))
        numeric('1')
        """
    def coeff (self):
        """
        >>> p.coeff (symbol ('a'))
        numeric('-2')
        >>> p.coeff (symbol ('a'),2)
        numeric('0')
        >>> q.lcoeff (symbol ('a'))
        symbol('b')
        """
    def lcoeff (self):
        """
        >>> p.lcoeff (symbol ('a'))
        numeric('-2')
        >>> q.lcoeff (symbol ('a'))
        symbol('b')
        """
    def tcoeff (self):
        """
        >>> p.tcoeff (symbol ('a'))
        numeric('-2')
        """
    def degree (self):
        """
        >>> p.degree (symbol ('a'))
        1
        >>> q.degree (symbol ('a'))
        1
        """
    def ldegree (self):
        """
        >>> p.ldegree (symbol ('a'))
        1
        >>> q.ldegree (symbol ('a'))
        1
        """
    def primpart (self):
        """
        >>> p.primpart (symbol ('a'))
        symbol('a')
        >>> q.primpart (symbol ('a'))
        symbol('a')
        """
    def content (self):
        """
        >>> p.content (symbol ('a'))
        numeric('2')
        >>> q.content (symbol ('a'))
        symbol('b')
        """
    def smod (self):
        """
        >>> p.smod (0)
        Traceback (most recent call last):
        ...
        ZeroDivisionError: division by zero
        >>> p.smod (1)
        symbol('a')
        >>> p.smod (2)
        numeric('0')
        >>> p.smod (3)
        symbol('a')
        >>> p.smod (4)
        mul(symbol('a'),numeric('2'))
        >>> p.smod (5)
        mul(symbol('a'),numeric('3'))
        >>> p.smod (6)
        mul(symbol('a'),numeric('-2'))
        >>> p.smod (-1)
        mul(symbol('a'),numeric('2'))
        >>> p.smod (-2)
        mul(symbol('a'),numeric('2'))
        >>> p.smod (-3)
        symbol('a')
        >>> p.smod (-4)
        mul(symbol('a'),numeric('2'))
        >>> q.smod (1)
        mul(symbol('b'),symbol('a'))
        >>> q.smod (2)
        mul(symbol('b'),symbol('a'))
        >>> q.smod (3)
        mul(symbol('b'),symbol('a'))
        >>> q.smod (-1)
        mul(symbol('b'),symbol('a'),numeric('2'))
        >>> q.smod (-2)
        mul(symbol('b'),symbol('a'))
        >>> q.smod (-3)
        mul(symbol('b'),symbol('a'))
        >>> q.smod (-6)
        mul(symbol('b'),symbol('a'))
        """
    def is_function (self):
        """
        >>> p.is_function ()
        0
        """
def _test():
    import test_mul
    return test_all.test(test_mul)

if __name__ == "__main__":
    _test()

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>