Detail: TypeClinic: Method
- TypeClinic.__call__(hint, /, *, fail_fast=False)[source]
Given a hint (a type and/or generic alias), return a
ClinicResult
object describing the result of the check.- Parameters:
fail_fast – If True, return on first failure. If False, all failures are discovered and reported.
>>> f = sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x') >>> f <Frame: x> <Index> a b c <<U1> <Index> 0 10 False 1517-01-01 1 2 True 1517-04-01 2 8 True 1517-12-31 3 3 False 1517-06-30 <int64> <int64> <bool> <datetime64[D]> >>> tc = sf.TypeClinic((f, True)) >>> tc(tuple[bool, bool]) <ClinicResult: 1 error> >>> tc(tuple[bool, bool]).to_str() In tuple[bool, bool] └── Expected bool, provided Frame invalid
- TypeClinic.check(hint, /, *, fail_fast=False)[source]
Given a hint (a type and/or generic alias), raise a
ClinicError
exception describing the result of the check if an error is found.- Parameters:
fail_fast – If True, return on first failure. If False, all failures are discovered and reported.
>>> f = sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x') >>> f <Frame: x> <Index> a b c <<U1> <Index> 0 10 False 1517-01-01 1 2 True 1517-04-01 2 8 True 1517-12-31 3 3 False 1517-06-30 <int64> <int64> <bool> <datetime64[D]> >>> tc = sf.TypeClinic((f, True)) >>> tc.check(tuple[bool, bool]) ClinicError('\nIn tuple[bool, bool]\n└── Expected bool, provided Frame invalid')
- TypeClinic.warn(hint, /, *, fail_fast=False, category=<class 'UserWarning'>)[source]
Given a hint (a type and/or generic alias), issue a warning describing the result of the check if an error is found.
- Parameters:
fail_fast – If True, return on first failure. If False, all failures are discovered and reported.
category – The
Warning
subclass to be used for issueing the warning.
TypeClinic: Constructor | Exporter | Method | Display