Package sage :: Package misc :: Module misc
[show private | hide private]
[frames | no frames]

Module sage.misc.misc

Miscellaneous functions for timing, verbosity, etc.
Classes
lazy_prop  

Function Summary
  add(x, z)
  add_nonempty(x)
  assert_attribute(x, attr, init)
If the object x has the attribute attr, do nothing.
  clock(cmd)
  cputime(t)
Return the time in CPU second since SAGE started, or with optional argument t, return the time since time t.
  generic_cmp(x, y)
  get_verbose()
  is_64bit()
  mul(x, z)
Return the product of the elements in the list x.
  parent(x)
Returns the parent of x, if x has a parent, otherwise return None.
  powerset(X)
Iterator over the *list* of all subsets of the iterable X, in no particular order.
  prod(x, z)
Return the product of the elements in the list x.
  prop(f)
  random_sublist(X, s)
Return a random sublist of the list X where the chance of including a particular element is s.
  repr_lincomb(symbols, lincomb)
  set_verbose(level)
Set the verbosity level.
  to_gmp_hex(n)
  todo(mesg)
  typecheck(x, C, var)
  union(x, y)
  uniq(x)
Return a sublist of the elements in the list x that is sorted and is such that the entries in the sublist are unique.
  verbose(mesg, t, level, caller_name)
  version()

Variable Summary
str LOGFILE = '/home/was/sage/log/sage_log'

Function Details

assert_attribute(x, attr, init=None)

If the object x has the attribute attr, do nothing. If not, set x.attr to init.

cputime(t=0)

Return the time in CPU second since SAGE started, or with optional
argument t, return the time since time t.
INPUT:
    t -- (optional) float, time in CPU seconds
OUTPUT:
    float -- time in CPU seconds

mul(x, z=None)

Return the product of the elements in the list x. If optimal argument z is not given, start the product with the first element of the list, otherwise use z.
>>> mul([1,2,34])
68

>>> mul([2,3], 5)
30

parent(x)

Returns the parent of x, if x has a parent, otherwise return None.

powerset(X)

Iterator over the *list* of all subsets of the iterable X,
in no particular order.  Each list appears exactly once,
up to order.

INPUT:
    X -- an iterable
OUTPUT:
    iterator of lists
EXAMPLES:
    >>> list(powerset([1,2,3]))
    [[], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3]]
    >>> for z in powerset([0,[1,2]]): print z,
    [] [0] [[1, 2]] [0, [1, 2]]

The reason we return lists instead of sets is that the elements
of sets must be hashable and many structures on which one wants
the powerset consist of non-hashable objects.

prod(x, z=None)

Return the product of the elements in the list x. If optimal argument z is not given, start the product with the first element of the list, otherwise use z.
>>> mul([1,2,34])
68

>>> mul([2,3], 5)
30

random_sublist(X, s)

Return a random sublist of the list X where the chance
of including a particular element is s.

INPUT:
    X -- list
    s -- floating point number between 0 and 1
OUTPUT:
    list

set_verbose(level)

Set the verbosity level.

INPUT:
   int level: an integer between 0 and 2, inclusive.
OUTPUT:
   changes the state of the verbosity flag.

uniq(x)

Return a sublist of the elements in the list x that is sorted and is such that the entries in the sublist are unique.

Variable Details

LOGFILE

Type:
str
Value:
'/home/was/sage/log/sage_log'                                          

Generated by Epydoc 2.1 on Mon Jun 20 15:43:22 2005 http://epydoc.sf.net