MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / contained_by

Method contained_by

lib/sqlalchemy/dialects/postgresql/ranges.py:295–322  ·  view source on GitHub ↗

Determine whether this range is a contained by `other`.

(self, other: Range[_T])

Source from the content-addressed store, hash-verified

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`."

Callers 12

containsMethod · 0.45
test_arrayMethod · 0.45
test_basic_py_sanityMethod · 0.45
test_contains_rangeMethod · 0.45
test_contained_byMethod · 0.45
test_contained_by_objMethod · 0.45

Calls 1

_compare_edgesMethod · 0.95

Tested by 10

test_arrayMethod · 0.36
test_basic_py_sanityMethod · 0.36
test_contains_rangeMethod · 0.36
test_contained_byMethod · 0.36
test_contained_by_objMethod · 0.36