Package esys :: Package pycad :: Module design :: Class TagMap
[hide private]
[frames] | no frames]

Class TagMap

object --+
         |
        TagMap

A class that allows to map tags to names.

Example:

   tm=TagMap({5 : x })
   tm.setMap(a=1,x=4)
   assert tm.getTags("a") == [ 1 ]
   assert tm.getTags("x") == [ 5, 4 ]
   assert tm.map(x=10., a=20.) == { 5 : 10, 4: 10, 1 : 20 }
Instance Methods [hide private]
 
__init__(self, mapping={})
Initializes the mapping.
 
fillFromXML(self, iostream)
Uses the XML file or string to set the mapping.
 
fromDom(self, node)
Fills names and tags from dom node.
 
getMapping(self)
Returns a dictionary where the tags define the keys and the values the corresponding names.
 
getName(self, tag=None)
Returns the name of a tag.
 
getTags(self, name=None)
Returns a list of the tags assigned to name.
 
insert(self, data, default=0, **kwargs)
Inserts values into the esys.escript.Data object according to the given values assigned to the keywords.
 
map(self, default=0, **kwargs)
Returns a dictionary where the tags define the keys and the values give the values assigned to the tag via name and kwargs:
 
passToDomain(self, domain)
Passes the tag map to the esys.escript.Domain domain.
 
setMap(self, **kwargs)
Sets a new map where <name>=<tag> assigns the tag <tag> to name <name>.
 
toDOM(self, dom)
Adds object to dom.
 
writeXML(self, iostream=None)
Serializes self as XML into iostream or if not present returns the XML as string.

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, mapping={})
(Constructor)

 

Initializes the mapping. mapping defines an initial mapping from tag to a name.

Overrides: object.__init__

getName(self, tag=None)

 

Returns the name of a tag. If tag is not present a list of all names is returned.

getTags(self, name=None)

 

Returns a list of the tags assigned to name. If name is not present a list of all tags is returned.

insert(self, data, default=0, **kwargs)

 

Inserts values into the esys.escript.Data object according to the given values assigned to the keywords. The default is used for tags which map onto name with unspecified values.

map(self, default=0, **kwargs)

 

Returns a dictionary where the tags define the keys and the values give the values assigned to the tag via name and kwargs:

   tm=TagMap(x=5)
   tm.setMap(a=1,x=4)
   print tm.map(x=10., a=20.)
   { 5 : 10, 4: 10, 1 : 20 }

The default is used for tags which map onto name with unspecified values.

setMap(self, **kwargs)

 

Sets a new map where <name>=<tag> assigns the tag <tag> to name <name>. <tag> has to be an integer. If <tag> has been assigned to a name before the mapping will be overwritten. Otherwise a new mapping <tag> -> <name> is set. Notice that a single name can be assigned to different tags.