Raises an exception if `self` is not compatible with the given `rank`. Args: rank: An integer. Raises: ValueError: If `self` does not represent a shape with the given `rank`.
(self, rank)
| 983 | (self, other)) |
| 984 | |
| 985 | def assert_has_rank(self, rank): |
| 986 | """Raises an exception if `self` is not compatible with the given `rank`. |
| 987 | |
| 988 | Args: |
| 989 | rank: An integer. |
| 990 | |
| 991 | Raises: |
| 992 | ValueError: If `self` does not represent a shape with the given `rank`. |
| 993 | """ |
| 994 | if self.rank not in (None, rank): |
| 995 | raise ValueError("Shape %s must have rank %d" % (self, rank)) |
| 996 | |
| 997 | def with_rank(self, rank): |
| 998 | """Returns a shape based on `self` with the given rank. |
no outgoing calls