StructuredType
Represents a structured type with a defined calculus to simplify the construction of combined types when writing parsers that take multi-typed data
Supports a compound StructuredType where the types are keyed
__init__(self, base_type, shape=None, is_alternative=False, is_optional=False, default_value=None):
@property
is_simple(self):
add_types(self, other):
Constructs a new type by treating the two objects as siblings, that is if they can be merged due to type and shape similarity they will be, otherwise a non-nesting structure will be constructed from them
We’ll also want a nesting version of this I’m guessing, which probably we hook into call
other
:Any
:returns
:_
__add__(self, other):
compound_types(self, other):
Creates a structured type where rather than merging types they simply compound onto one another
other
:Any
:returns
:_
__call__(self, other):
repeat(self, n=None, m=None):
Returns a new version of the type, but with the appropriate shape for being repeated n-to-m times
n
:Any
m
:Any
:returns
:_
drop_axis(self, axis=0):
Returns a new version of the type, but with the appropriate shape for dropping an axis
axis
:int
:returns
:_
extend_shape(self, base_shape):
Extends the shape of the type such that base_shape precedes the existing shape
base_shape
:Any
:returns
:_
__repr__(self):