Detail: Bus: Accessor Type Clinic

Overview: Bus: Accessor Type Clinic

Bus.via_type_clinic.to_hint
Bus.via_type_clinic
TypeClinic.to_hint()[source]

Return the type hint (the type and/or generic aliases necessary) to represent the object given at initialization.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame((np.arange(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), name='i')
>>> b
<Bus: i>
<Index>
x        Frame
y        Frame
<<U1>    <object>
>>> b.via_type_clinic.to_hint()
static_frame.core.bus.Bus[static_frame.core.index.Index[numpy.str_]]
Bus.via_type_clinic.check(hint, *, fail_fast)
Bus.via_type_clinic
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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame((np.arange(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), name='i')
>>> b
<Bus: i>
<Index>
x        Frame
y        Frame
<<U1>    <object>
>>> b.via_type_clinic.check(sf.Bus[sf.Index[np.int64]])
ClinicError('\nIn Bus[Index[int64]]\n└── Index[int64]\n    └── Expected int64, provided str_ invalid')
Bus.via_type_clinic.warn(hint, *, fail_fast, category)
Bus.via_type_clinic
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.

Bus.via_type_clinic.__call__(hint, *, fail_fast)
Bus.via_type_clinic
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.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame((np.arange(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), name='i')
>>> b
<Bus: i>
<Index>
x        Frame
y        Frame
<<U1>    <object>
>>> cr = b.via_type_clinic(sf.Bus[sf.Index[np.int64]])
>>> cr
<ClinicResult: 1 error>
>>> cr.validated
False
>>> cr.to_str()

In Bus[Index[int64]]
└── Index[int64]
    └── Expected int64, provided str_ invalid
Bus.via_type_clinic.__repr__
Bus.via_type_clinic
TypeClinic.__repr__()[source]

Return a compact string representation of the type hint (the type and/or generic aliases necessary) to represent the object given at initialization.

>>> b = sf.Bus.from_frames((sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x'), sf.Frame((np.arange(6).reshape(3,2) % 2).astype(bool), index=('p', 'q', 'r'), columns=('c', 'd'), name='y')), name='i')
>>> b
<Bus: i>
<Index>
x        Frame
y        Frame
<<U1>    <object>
>>> b.via_type_clinic
Bus[Index[str_]]

Bus: Constructor | Exporter | Attribute | Method | Dictionary-Like | Display | Selector | Iterator | Accessor Hashlib | Accessor Type Clinic