MCPcopy
hub / github.com/pandas-dev/pandas / validate_inclusive

Function validate_inclusive

pandas/util/_validators.py:424–455  ·  view source on GitHub ↗

Check that the `inclusive` argument is among {"both", "neither", "left", "right"}. Parameters ---------- inclusive : {"both", "neither", "left", "right"} Returns ------- left_right_inclusive : tuple[bool, bool] Raises ------ ValueError : if argument is not

(inclusive: str | None)

Source from the content-addressed store, hash-verified

422
423
424def validate_inclusive(inclusive: str | None) -> tuple[bool, bool]:
425 """
426 Check that the `inclusive` argument is among {"both", "neither", "left", "right"}.
427
428 Parameters
429 ----------
430 inclusive : {"both", "neither", "left", "right"}
431
432 Returns
433 -------
434 left_right_inclusive : tuple[bool, bool]
435
436 Raises
437 ------
438 ValueError : if argument is not among valid values
439 """
440 left_right_inclusive: tuple[bool, bool] | None = None
441
442 if isinstance(inclusive, str):
443 left_right_inclusive = {
444 "both": (True, True),
445 "left": (True, False),
446 "right": (False, True),
447 "neither": (False, False),
448 }.get(inclusive)
449
450 if left_right_inclusive is None:
451 raise ValueError(
452 "Inclusive has to be either 'both', 'neither', 'left' or 'right'"
453 )
454
455 return left_right_inclusive
456
457
458def validate_insert_loc(loc: int, length: int) -> int:

Callers 4

between_timeMethod · 0.90
_generate_rangeMethod · 0.90
test_invalid_inclusiveFunction · 0.90
test_valid_inclusiveFunction · 0.90

Calls 1

getMethod · 0.45

Tested by 2

test_invalid_inclusiveFunction · 0.72
test_valid_inclusiveFunction · 0.72