Package sympycore :: Package basealgebra :: Module algebra :: Class Algebra
[hide private]
[frames] | no frames]

Class Algebra

source code


Represents an element of an algebraic structure.

This class collects implementation specific methods of algebra classes.

For implemented algebras, see:

Verbatim CollectingField

New algebras may need to redefine the following methods:

__new__(cls, ...)
convert(cls, obj, typeerror=True)
convert_coefficient(cls, obj, typeerror=True)
convert_exponent(cls, obj, typeerror=True)
as_verbatim(self)
as_algebra(self, cls)

and the following properties:

args(self)
func(self)


Instance Methods [hide private]
 
__nonzero__(self) source code
call graph 
 
__repr__(self) source code
call graph 
 
__str__(self)
str(x)
source code
call graph 
 
_matches(pattern, expr, repl_dict, wild_info) source code
 
_subs(self, subexpr, newexpr) source code
 
as_algebra(self, cls)
Convert algebra to another algebra.
source code
 
as_tree(self, tab='', level=0) source code
 
as_verbatim(self) source code
 
has(self, obj)
Return True if self contains atomic expression obj.
source code
 
match(self, pattern, *wildcards)
Pattern matching.
source code
call graph 
 
matches(pattern, expr, repl_dict={}, wild_info=None) source code
call graph 
 
subs(self, subexpr, newexpr=None)
Substitute a sub-expression with new expression.
source code
call graph 

Inherited from expr.Expr: __eq__, __ge__, __gt__, __hash__, __init__, __le__, __lt__, __ne__, __reduce__, as_lowlevel

Inherited from expr.Expr (private): _sethash

Inherited from object: __delattr__, __getattribute__, __new__, __reduce_ex__, __setattr__

Class Methods [hide private]
 
Number(cls, num, denom=None)
Construct algebra number directly from obj.
source code
 
Symbol(cls, obj)
Construct algebra symbol directly from obj.
source code
 
_matches_seq(cls, pattern_seq, expr_seq, repl_dict, wild_info) source code
call graph 
 
convert(cls, obj, typeerror=True)
Convert obj to algebra element.
source code
call graph 
 
convert_coefficient(cls, obj, typeerror=True)
Convert obj to coefficient algebra.
source code
call graph 
 
convert_exponent(cls, obj, typeerror=True)
Convert obj to exponent algebra.
source code
call graph 
 
disable_symbolic_comparison(cls, name='equality')
Disable returning Logic instances from relational methods.
source code
 
enable_symbolic_comparison(cls, name='equality')
Enable returning Logic instances from relational methods.
source code
 
get_predefined_symbols(cls, name) source code
call graph 
Class Variables [hide private]
  _str_value = None
  coefftypes = (<type 'int'>, <type 'long'>)
  exptypes = (<type 'int'>, <type 'long'>)
Properties [hide private]
  args
Returns a sequence such that self.func(*self.args) == self.
  func
Returns a callable such that self.func(*self.args) == self.
  symbols
Return a set of atomic subexpressions in a symbolic object.

Inherited from expr.Expr: data, head, is_writable, pair

Inherited from expr.Expr (private): _hash

Inherited from object: __class__

Method Details [hide private]

__nonzero__(self)
(Boolean test operator)

source code 
call graph 
Overrides: expr.Expr.__nonzero__

__repr__(self)
(Representation operator)

source code 
call graph 
Overrides: expr.Expr.__repr__

__str__(self)
(Informal representation operator)

source code 
call graph 
str(x)
Overrides: object.__str__
(inherited documentation)

as_algebra(self, cls)

source code 

Convert algebra to another algebra.

This method uses default conversation via verbatim algebra that might not be the most efficient. For efficiency, algebras should redefine this method to implement direct conversation.

convert(cls, obj, typeerror=True)
Class Method

source code 
call graph 

Convert obj to algebra element.

Set typeerror=False when calling from operation methods like __add__, __mul__, etc.

match(self, pattern, *wildcards)

source code 
call graph 

Pattern matching.

Return None when expression (self) does not match with pattern. Otherwise return a dictionary such that

pattern.subs_dict(self.match(pattern, *wildcards)) == self

Don't redefine this method, redefine matches(..) method instead.

subs(self, subexpr, newexpr=None)

source code 
call graph 

Substitute a sub-expression with new expression.

There are two usage forms:

obj.subs(subexpr, newexpr)
obj.subs([(subexpr1, newexpr1), (subexpr2, newexpr2), ..])

Property Details [hide private]

args

Returns a sequence such that self.func(*self.args) == self.
Get Method:
unreachable.args(self) - Returns a sequence such that self.func(*self.args) == self.

func

Returns a callable such that self.func(*self.args) == self.
Get Method:
unreachable.func(self) - Returns a callable such that self.func(*self.args) == self.

symbols

Return a set of atomic subexpressions in a symbolic object.
Get Method:
unreachable.symbols(self) - Return a set of atomic subexpressions in a symbolic object.