def test_float_to_string(self, floating, string): assert np.can_cast(floating, string) # 100 is long enough to hold any formatted floating if uses_new_casts(): assert np.can_cast(floating, f"{string}100") else: assert not np.can_cast(floating, f"{string}100") assert np.can_cast(floating, f"{string}100", casting="same_kind")
def test_to_void(self): # But in general, we do consider these safe: assert np.can_cast("d", "V") assert np.can_cast("S20", "V") # Do not consider it a safe cast if the void is too smaller: if uses_new_casts(): assert not np.can_cast("d", "V1") assert not np.can_cast("S20", "V1") assert not np.can_cast("U1", "V1") # Structured to unstructured is just like any other: assert np.can_cast("d,i", "V", casting="same_kind") else: assert np.can_cast("d", "V1") assert np.can_cast("S20", "V1") assert np.can_cast("U1", "V1") assert not np.can_cast("d,i", "V", casting="same_kind")