Determine whether this range is a contained by `other`.
(self, other: Range[_T])
| 293 | ) |
| 294 | |
| 295 | def contained_by(self, other: Range[_T]) -> bool: |
| 296 | "Determine whether this range is a contained by `other`." |
| 297 | |
| 298 | # Any range contains the empty one |
| 299 | if self.empty: |
| 300 | return True |
| 301 | |
| 302 | # An empty range does not contain any range except the empty one |
| 303 | if other.empty: |
| 304 | return False |
| 305 | |
| 306 | slower = self.lower |
| 307 | slower_b = self.bounds[0] |
| 308 | olower = other.lower |
| 309 | olower_b = other.bounds[0] |
| 310 | |
| 311 | if self._compare_edges(slower, slower_b, olower, olower_b) < 0: |
| 312 | return False |
| 313 | |
| 314 | supper = self.upper |
| 315 | supper_b = self.bounds[1] |
| 316 | oupper = other.upper |
| 317 | oupper_b = other.bounds[1] |
| 318 | |
| 319 | if self._compare_edges(supper, supper_b, oupper, oupper_b) > 0: |
| 320 | return False |
| 321 | |
| 322 | return True |
| 323 | |
| 324 | def contains(self, value: Union[_T, Range[_T]]) -> bool: |
| 325 | "Determine whether this range contains `value`." |