Permutes a shape from one format to another. Args: shape (Tuple[int]): The shape to convert. new_format (DataFormat): The desired format of the shape. Returns: Tuple[int]: A new shape in the correct format.
(shape, new_format)
| 104 | |
| 105 | @staticmethod |
| 106 | def convert(shape, new_format): |
| 107 | """ |
| 108 | Permutes a shape from one format to another. |
| 109 | |
| 110 | Args: |
| 111 | shape (Tuple[int]): The shape to convert. |
| 112 | new_format (DataFormat): The desired format of the shape. |
| 113 | |
| 114 | Returns: |
| 115 | Tuple[int]: A new shape in the correct format. |
| 116 | """ |
| 117 | old_format = FormatManager.determine_format(shape) |
| 118 | perm = FormatManager.permutation(old_format, new_format) |
| 119 | return [shape[index] if index != -1 else 1 for index in perm] |
no test coverage detected