View source on GitHub |
A representation of a structure paired with a Python container type.
Inherits From: StructType
, Struct
, Type
tff.types.StructWithPythonType(
elements: Iterable[object], container_type: type[object]
)
Args | |
---|---|
elements
|
An iterable of element specifications. Each element
specification is either a type spec (an instance of tff.Type or
something convertible to it via tff.types.to_type ) for the element, or
a (name, spec) for elements that have defined names. Alternatively, one
can supply here an instance of collections.OrderedDict mapping element
names to their types (or things that are convertible to types).
|
convert
|
A flag to determine if the elements should be converted using
tff.types.to_type or not.
|
Attributes | |
---|---|
python_container
|
Methods
check_assignable_from
check_assignable_from(
source_type: 'Type'
) -> None
Raises if values of source_type
cannot be cast to this type.
check_equivalent_to
check_equivalent_to(
other: 'Type'
) -> None
Raises if values of 'other' cannot be cast to and from this type.
check_identical_to
check_identical_to(
other: 'Type'
) -> None
Raises if other
and Type
are not exactly identical.
children
children() -> Iterator[Type]
Returns a generator yielding immediate child types.
compact_representation
compact_representation() -> str
Returns the compact string representation of this type.
formatted_representation
formatted_representation() -> str
Returns the formatted string representation of this type.
is_assignable_from
is_assignable_from(
source_type: tff.types.Type
) -> bool
Returns whether values of source_type
can be cast to this type.
is_equivalent_to
is_equivalent_to(
other: 'Type'
) -> bool
Returns whether values of other
can be cast to and from this type.
is_identical_to
is_identical_to(
other: 'Type'
) -> bool
Returns whether or not self
and other
are exactly identical.
named
@classmethod
named( **kwargs ) -> 'Struct'
Constructs a new Struct
with all named elements.
unnamed
@classmethod
unnamed( *args ) -> 'Struct'
Constructs a new Struct
with all unnamed elements.
__eq__
__eq__(
other
)
Return self==value.
__getitem__
__getitem__(
key: Union[int, str, slice]
) -> _T
__iter__
__iter__() -> Iterator[_T]
__len__
__len__() -> int
__ne__
__ne__(
other: object
) -> bool
Return self!=value.