tff.types.StructType
Stay organized with collections
Save and categorize content based on your preferences.
An implementation of tff.Type
representing structural types in TFF.
Inherits From: Struct
, Type
tff.types.StructType(
elements: Iterable[object], *, convert: bool = True
)
Elements initialized by name can be accessed as foo.name
, and otherwise by
index, foo[index]
.
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
View source
check_assignable_from(
source_type: 'Type'
) -> None
Raises if values of source_type
cannot be cast to this type.
check_equivalent_to
View source
check_equivalent_to(
other: 'Type'
) -> None
Raises if values of 'other' cannot be cast to and from this type.
check_identical_to
View source
check_identical_to(
other: 'Type'
) -> None
Raises if other
and Type
are not exactly identical.
children
View source
children() -> Iterator[Type]
Returns a generator yielding immediate child types.
compact_representation
View source
compact_representation() -> str
Returns the compact string representation of this type.
View source
formatted_representation() -> str
Returns the formatted string representation of this type.
is_assignable_from
View source
is_assignable_from(
source_type: tff.types.Type
) -> bool
Returns whether values of source_type
can be cast to this type.
is_equivalent_to
View source
is_equivalent_to(
other: 'Type'
) -> bool
Returns whether values of other
can be cast to and from this type.
is_identical_to
View source
is_identical_to(
other: 'Type'
) -> bool
Returns whether or not self
and other
are exactly identical.
named
View source
@classmethod
named(
**kwargs
) -> 'Struct'
Constructs a new Struct
with all named elements.
unnamed
View source
@classmethod
unnamed(
*args
) -> 'Struct'
Constructs a new Struct
with all unnamed elements.
__eq__
View source
__eq__(
other
)
Return self==value.
__getitem__
View source
__getitem__(
key: Union[int, str, slice]
) -> _T
__iter__
View source
__iter__() -> Iterator[_T]
__len__
View source
__len__() -> int
__ne__
View source
__ne__(
other: object
) -> bool
Return self!=value.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-27 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-27 UTC."],[],[],null,["# tff.types.StructType\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |\n\nAn implementation of [`tff.Type`](../../tff/types/Type) representing structural types in TFF.\n\nInherits From: [`Struct`](../../tff/structure/Struct), [`Type`](../../tff/types/Type)\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tff.StructType`](https://www.tensorflow.org/federated/api_docs/python/tff/types/StructType)\n\n\u003cbr /\u003e\n\n tff.types.StructType(\n elements: Iterable[object], *, convert: bool = True\n )\n\nElements initialized by name can be accessed as `foo.name`, and otherwise by\nindex, `foo[index]`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `elements` | An iterable of element specifications. Each element specification is either a type spec (an instance of [`tff.Type`](../../tff/types/Type) or something convertible to it via [`tff.types.to_type`](../../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). |\n| `convert` | A flag to determine if the elements should be converted using [`tff.types.to_type`](../../tff/types/to_type) or not. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|--------------------|---------------|\n| `python_container` | \u003cbr /\u003e \u003cbr /\u003e |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `check_assignable_from`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n check_assignable_from(\n source_type: 'Type'\n ) -\u003e None\n\nRaises if values of `source_type` cannot be cast to this type.\n\n### `check_equivalent_to`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n check_equivalent_to(\n other: 'Type'\n ) -\u003e None\n\nRaises if values of 'other' cannot be cast to and from this type.\n\n### `check_identical_to`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n check_identical_to(\n other: 'Type'\n ) -\u003e None\n\nRaises if `other` and `Type` are not exactly identical.\n\n### `children`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n children() -\u003e Iterator[Type]\n\nReturns a generator yielding immediate child types.\n\n### `compact_representation`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n compact_representation() -\u003e str\n\nReturns the compact string representation of this type.\n\n### `formatted_representation`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n formatted_representation() -\u003e str\n\nReturns the formatted string representation of this type.\n\n### `is_assignable_from`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n is_assignable_from(\n source_type: ../../tff/types/Type\n ) -\u003e bool\n\nReturns whether values of `source_type` can be cast to this type.\n\n### `is_equivalent_to`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n is_equivalent_to(\n other: 'Type'\n ) -\u003e bool\n\nReturns whether values of `other` can be cast to and from this type.\n\n### `is_identical_to`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n is_identical_to(\n other: 'Type'\n ) -\u003e bool\n\nReturns whether or not `self` and `other` are exactly identical.\n\n### `named`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n @classmethod\n named(\n **kwargs\n ) -\u003e 'Struct'\n\nConstructs a new `Struct` with all named elements.\n\n### `unnamed`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n @classmethod\n unnamed(\n *args\n ) -\u003e 'Struct'\n\nConstructs a new `Struct` with all unnamed elements.\n\n### `__eq__`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n __eq__(\n other\n )\n\nReturn self==value.\n\n### `__getitem__`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n __getitem__(\n key: Union[int, str, slice]\n ) -\u003e _T\n\n### `__iter__`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n __iter__() -\u003e Iterator[_T]\n\n### `__len__`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n __len__() -\u003e int\n\n### `__ne__`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n __ne__(\n other: object\n ) -\u003e bool\n\nReturn self!=value."]]