Returns a shape based on `self` with the given rank. This method promotes a completely unknown shape to one with a known rank. Args: rank: An integer. Returns: A shape that is at least as specific as `self` with the given rank. Raises: ValueError: If `self`
(self, 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. |
| 999 | |
| 1000 | This method promotes a completely unknown shape to one with a |
| 1001 | known rank. |
| 1002 | |
| 1003 | Args: |
| 1004 | rank: An integer. |
| 1005 | |
| 1006 | Returns: |
| 1007 | A shape that is at least as specific as `self` with the given rank. |
| 1008 | |
| 1009 | Raises: |
| 1010 | ValueError: If `self` does not represent a shape with the given `rank`. |
| 1011 | """ |
| 1012 | try: |
| 1013 | return self.merge_with(unknown_shape(rank=rank)) |
| 1014 | except ValueError: |
| 1015 | raise ValueError("Shape %s must have rank %d" % (self, rank)) |
| 1016 | |
| 1017 | def with_rank_at_least(self, rank): |
| 1018 | """Returns a shape based on `self` with at least the given rank. |
no test coverage detected