File:  [CENS] / python / pyGiNaC / test4 / test_lst.py
Revision 1.3: 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_symbol - run ginac.symbol tests.
  Usage:
    python test_symbol.py [-v]
"""
"""
  This file is part of the PyGiNaC package.
  http://cens.ioc.ee/projects/pyginac/

  $Revision: 1.3 $
  $Id: test_lst.py,v 1.3 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_lst(ginac.lst):
    """
    >>> test_save (l=lst (2,symbol ('a')))
    """
    def __init__(self):
        """See also __repr__
        >>> lst(lst())
        lst(lst())
        >>> lst(lst(lst()))
        lst(lst(lst()))
        >>> lst(symbol('a'))
        lst(symbol('a'))
        """
    def __repr__(self):
        """
        >>> lst()
        lst()
        >>> lst(lst (1,2))
        lst(lst(numeric('1'),numeric('2')))
        >>> lst ([1,2])
        lst(matrix([[numeric('1')],[numeric('2')]]))
        """
    def __str__(self):
        """
        >>> print lst()
        []
        >>> print lst(1,2)
        [1,2]
        >>> print lst(lst(1,2))
        [[1,2]]
        """
    def get_class_name(self):
        """
        >>> lst().get_class_name()
        'lst'
        """
    def get_precedence(self):
        """
        >>> lst().get_precedence()
        10
        """
    def extract_archived(self):
        """
        >>> lst().extract_archived()
        {'class': 'lst'}
        >>> lst(1).extract_archived(-1)
        {'seq': [{'number': '1', 'class': 'numeric'}], 'class': 'lst'}
        >>> lst(1,2).extract_archived()
        {'seq': [{'number': '1', 'class': 'numeric'}, {'number': '2', 'class': 'numeric'}], 'class': 'lst'}
        """
    def to_context(self):
        """
        >>> lst().to_context()
        '[]'
        >>> lst().to_context('python_repr')
        'lst()'
        >>> lst().to_context('context')
        '{}'
        >>> lst().to_context('latex')
        '{}'
        >>> lst().to_context('csrc')
        '{}'
        >>> lst(1,2).to_context()
        '[1,2]'
        """
    def is_equal(self):
        """
        >>> lst().is_equal(lst ( ))
        1
        >>> lst().is_equal(lst ( 1))
        0
        >>> s = symbol('s')
        >>> lst(3,s).is_equal(lst (3,s))
        1
        >>> lst(3,s).is_equal(lst ( 4,s))
        0
        """
    def is_zero(self):
        """
        >>> lst().is_zero()
        0
        >>> lst(0).is_zero()
        0
        """
    def to_list(self):
        """
        >>> lst().to_list()
        []
        >>> lst(1).to_list()
        [numeric('1')]
        >>> type(lst(1,2).to_list())
        <type 'list'>
        """
    def __getitem__ (self):
        """
        >>> l[0]
        numeric('2')
        >>> l[1]
        symbol('a')
        >>> l[2]
        Traceback (most recent call last):
        ...
        IndexError: invalid index
        >>> l[-1]
        symbol('a')
        >>> r = lst (*range(6))
        >>> r[:3]
        lst(numeric('0'),numeric('1'),numeric('2'))
        >>> r[:3:-1]
        lst(numeric('5'),numeric('4'))
        >>> r[2:4]
        lst(numeric('2'),numeric('3'))
        >>> r[::-1]
        lst(numeric('5'),numeric('4'),numeric('3'),numeric('2'),numeric('1'),numeric('0'))
        >>> r[::2]
        lst(numeric('0'),numeric('2'),numeric('4'))
        """
    def __setitem__ (self):
        """
        >>> r = lst (*range(4))
        >>> r[1] = 15
        >>> r
        lst(numeric('0'),numeric('15'),numeric('2'),numeric('3'))
        >>> r[1:3] = 56
        >>> r
        lst(numeric('0'),numeric('56'),numeric('56'),numeric('3'))
        >>> r[:2] = [28,7]
        >>> r
        lst(numeric('28'),numeric('7'),numeric('56'),numeric('3'))
        >>> r[1:3] = r[::3]
        >>> r
        lst(numeric('28'),numeric('28'),numeric('3'),numeric('3'))
        """
    def __len__ (self):
        """
        >>> len (l)
        2
        """
    def __nonzero__ (self):
        """
        >>> not l
        0
        >>> not lst ()
        1
        """
    def eval (self):
        """
        >>> l.eval ()
        lst(numeric('2'),symbol('a'))
        """
    def evalm (self):
        """
        >>> l.evalm ()
        lst(numeric('2'),symbol('a'))
        """
    def evalf (self):
        """
        >>> l.evalf ()
        lst(numeric('2.0'),symbol('a'))
        """
    def get_hash (self):
        """
        >>> type (l.get_hash ()) is type (0)
        1
        """
    def has (self):
        """
        >>> l.has (symbol ('a'))
        1
        >>> l.has (l)
        1
        >>> l.has (2)
        1
        >>> l.has (3)
        0
        >>> l.has (symbol ('b'))
        0
        """
    def is_function (self):
        """
        >>> l.is_function ()
        0
        """
    def nops (self):
        """
        >>> l.nops ()
        2
        """
    def op (self):
        """
        >>> l.op (1)
        symbol('a')
        """
    def swap (self):
        """
        >>> b=symbol ('b')
        >>> l.swap (b)
        >>> l,b
        (symbol('b'), lst(numeric('2'),symbol('a')))
        >>> l.swap (b)
        >>> l,b
        (lst(numeric('2'),symbol('a')), symbol('b'))
        """
    def append (self):
        """
        >>> v = lst (1,2)
        >>> print v
        [1,2]
        >>> v.append (symbol ('a'))
        >>> print v
        [1,2,a]
        """
    def prepend (self):
        """
        >>> v = lst (1,2)
        >>> v.prepend (symbol ('a'))
        >>> print v
        [a,1,2]
        """
    def sort (self):
        """
        >>> v = lst (7,1,symbol ('a'), -3,2)
        >>> v.sort ()
        >>> print v
        [a,1,2,7,-3]
        """
    def unique (self):
        """
        >>> v=lst (symbol ('a'),symbol ('a'),2)
        >>> v.unique ()
        >>> print v
        [a,2]
        """
    def remove_last (self):
        """
        >>> v = lst (7,1,symbol ('a'), -3,2)
        >>> print v
        [7,1,a,-3,2]
        >>> v.remove_last ()
        >>> print v
        [7,1,a,-3]
        """
    def remove_first (self):
        """
        >>> v = lst (7,1,symbol ('a'), -3,2)
        >>> v.remove_first ()
        >>> print v
        [1,a,-3,2]
        """
def _test():
    import test_lst
    return test_all.test(test_lst)

if __name__ == "__main__":
    _test()

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