Ejemplo n.º 1
0
            "textual_float_nan",
            "int_str_range",
            "str_float_non_leading_zeros",
            "str_int_zeros",
            # "string_with_sep_num_nan",
        },
    ),
    (DateTime, String,
     {"timestamp_string_series", "string_date", "py_datetime_str"}),
    (Boolean, String, {"string_bool_nan"}),
    (Float, Complex, {"complex_series_float", "complex_series_py_float"}),
    (Boolean, Object, {"bool_nan_series", "mixed", "nullable_bool_series"}),
]


@pytest.mark.parametrize(**get_convert_cases(array, convert_map, typeset))
def test_conversion(name, source_type, relation_type, series, member):
    """Test the generated combinations for "convert(array) == type" and "infer(array) = source_type"

    Args:
        series: the array to test
        type: the type to test against
    """
    result, message = convert(name, source_type, relation_type, series, member)
    assert result, message


cast_results = {
    "float_series2":
    pd.Series([1, 2, 3, 4], dtype=np.int64),
    "int_nan_series":
            "str_int_leading_zeros",
            "mixed",
            "categorical_complex_series",
            "int_series",
            "categorical_int_series",
            "categorical_float_series",
        },
    ),
    (
        Boolean,
        Categorical,
        {
            "string_bool_nan",
            "nullable_bool_series",
        },
    ),
]


@pytest.mark.parametrize(**get_convert_cases(series, convert_map, typeset))
def test_conversion(source_type, relation_type, series, member):
    """Test the generated combinations for "convert(series) == type" and "infer(series) = source_type"

    Args:
        series: the series to test
        type: the type to test against
    """
    config["vars"]["num"]["low_categorical_threshold"].set(0)
    result, message = convert(source_type, relation_type, series, member)
    assert result, message
            "categorical_complex_series",
            "int_series",
            "categorical_int_series",
            "categorical_float_series",
        },
    ),
    (
        Boolean,
        Categorical,
        {
            "string_bool_nan",
            "nullable_bool_series",
        },
    ),
]


@pytest.mark.parametrize(**get_convert_cases(series, convert_map,
                                             my_typeset_default))
def test_conversion(name, source_type, relation_type, series, member):
    """Test the generated combinations for "convert(series) == type" and "infer(series) = source_type"

    Args:
        name: the test name
        source_type: the type to test against
        relation_type: the type to test against
        series: the series to test
    """
    result, message = convert(name, source_type, relation_type, series, member)
    assert result, message