Package gavo :: Package adql :: Module fieldinfo :: Class Coercions
[frames] | no frames]

Class Coercions

source code

object --+
         |
        Coercions

A tree of types that can be used to infer common types.

The tree is passed in as nested sequences.

>>> c = Coercions(_CoercNode('bar', (_CoercNode('foo'), _CoercNode('baz',
...   (_CoercNode('quux'),)))))
>>> c.getSubsuming([])
'bar'
>>> c.getSubsuming(['foo'])
'foo'
>>> c.getSubsuming(['foo', 'foo'])
'foo'
>>> c.getSubsuming(['foo', 'quux'])
'bar'
>>> c.getSubsuming(['foo', 'weird'])
'bar'
Instance Methods
 
__init__(self, typeTree)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
getSubsuming(self, typeSeq)
returns the least general type being able to represent all types within typeSeq.
source code

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

Properties

Inherited from object: __class__

Method Details

__init__(self, typeTree)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

getSubsuming(self, typeSeq)

source code 

returns the least general type being able to represent all types within typeSeq.

The method returns the root type for both an empty typeSeq or a typeSeq containing an unknown type. We don't want to fail here, and the "all-encompassing" type should handle any crap.