Detail: IndexHierarchy: Accessor Type Clinic

Overview: IndexHierarchy: Accessor Type Clinic

IndexHierarchy.via_type_clinic.to_hint
IndexHierarchy.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.

>>> ih = sf.IndexHierarchy.from_labels((('b', 1024, True), ('a', 1024, True), ('a', 2048, True), ('a', 2048, False)), name='x')
>>> ih
<IndexHierarchy: x>
b                   1024    True
a                   1024    True
a                   2048    True
a                   2048    False
<<U1>               <int64> <bool>
>>> ih.via_type_clinic.to_hint()
static_frame.core.index_hierarchy.IndexHierarchy[static_frame.core.index.Index[numpy.str_], static_frame.core.index.Index[numpy.int64], static_frame.core.index.Index[numpy.bool_]]
IndexHierarchy.via_type_clinic.check(hint, *, fail_fast)
IndexHierarchy.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.

>>> ih = sf.IndexHierarchy.from_labels((('b', 1024, True), ('a', 1024, True), ('a', 2048, True), ('a', 2048, False)), name='x')
>>> ih
<IndexHierarchy: x>
b                   1024    True
a                   1024    True
a                   2048    True
a                   2048    False
<<U1>               <int64> <bool>
>>> ih.via_type_clinic.check(sf.IndexHierarchy[sf.Index[np.str_], sf.Index[np.bool_]])
ClinicError('\nIn IndexHierarchy[Index[str_], Index[bool_]]\n└── Expected IndexHierarchy has 2 depth, provided IndexHierarchy has 3 depth')
IndexHierarchy.via_type_clinic.warn(hint, *, fail_fast, category)
IndexHierarchy.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.

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

>>> ih = sf.IndexHierarchy.from_labels((('b', 1024, True), ('a', 1024, True), ('a', 2048, True), ('a', 2048, False)), name='x')
>>> ih
<IndexHierarchy: x>
b                   1024    True
a                   1024    True
a                   2048    True
a                   2048    False
<<U1>               <int64> <bool>
>>> cr = ih.via_type_clinic(sf.IndexHierarchy[sf.Index[np.str_], sf.Index[np.bool_]])
>>> cr
<ClinicResult: 1 error>
>>> cr.validated
False
>>> cr.to_str()

In IndexHierarchy[Index[str_], Index[bool_]]
└── Expected IndexHierarchy has 2 depth, provided IndexHierarchy has 3 depth
IndexHierarchy.via_type_clinic.__repr__
IndexHierarchy.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.

>>> ih = sf.IndexHierarchy.from_labels((('b', 1024, True), ('a', 1024, True), ('a', 2048, True), ('a', 2048, False)), name='x')
>>> ih
<IndexHierarchy: x>
b                   1024    True
a                   1024    True
a                   2048    True
a                   2048    False
<<U1>               <int64> <bool>
>>> ih.via_type_clinic
IndexHierarchy[Index[str_], Index[int64], Index[bool_]]

IndexHierarchy: Constructor | Exporter | Attribute | Method | Dictionary-Like | Display | Selector | Iterator | Operator Binary | Operator Unary | Accessor Values | Accessor Datetime | Accessor String | Accessor Transpose | Accessor Regular Expression | Accessor Hashlib | Accessor Type Clinic