def _get_relations(cls) -> Sequence[TypeRelation]: from visions.types import Generic, String, Complex relations = [ IdentityRelation(cls, Generic), InferenceRelation(cls, String, relationship=test_string_is_float, transformer=to_float), InferenceRelation( cls, Complex, relationship=lambda s: all(np.imag(s.values) == 0), transformer=suppress_warnings(to_float), ), ] return relations
def _get_relations() -> Sequence[TypeRelation]: from visions.core.implementations.types import ( visions_generic, visions_string, visions_complex, ) relations = [ IdentityRelation(visions_float, visions_generic), InferenceRelation( visions_float, visions_string, relationship=test_string_is_float, transformer=to_float, ), InferenceRelation( visions_float, visions_complex, relationship=lambda s: all(np.imag(s.values) == 0), transformer=suppress_warnings(to_float), ), ] return relations
def complex_to_float(series: pd.Series, state: dict) -> pd.Series: return suppress_warnings(lambda s: s.astype(float))(series)
def complex_to_float(series, state: dict): return suppress_warnings(to_float)(series, state)
def complex_to_float(array: np.array, state: dict) -> np.ndarray: return suppress_warnings(lambda s: s.astype(np.float_))(array)