Esempio n. 1
0
    def __init__(
        self,
        max_capping_dict: Optional[dict] = None,
        min_capping_dict: Optional[dict] = None,
        missing_values: str = "raise",
    ) -> None:

        if not max_capping_dict and not min_capping_dict:
            raise ValueError(
                "Please provide at least 1 dictionary with the capping values."
            )

        if missing_values not in ["raise", "ignore"]:
            raise ValueError("missing_values takes only values 'raise' or 'ignore'")

        self.max_capping_dict = _define_numerical_dict(max_capping_dict)
        self.min_capping_dict = _define_numerical_dict(min_capping_dict)
        self.missing_values = missing_values
Esempio n. 2
0
    def __init__(self,
                 arbitrary_number=999,
                 variables=None,
                 imputer_dict=None):

        if isinstance(arbitrary_number, int) or isinstance(
                arbitrary_number, float):
            self.arbitrary_number = arbitrary_number
        else:
            raise ValueError(
                "arbitrary_number must be numeric of type int or float")

        self.variables = _define_variables(variables)

        self.imputer_dict = _define_numerical_dict(imputer_dict)
Esempio n. 3
0
    def __init__(
        self,
        arbitrary_number: Union[int, float] = 999,
        variables: Union[None, int, str, List[Union[str, int]]] = None,
        imputer_dict: Optional[dict] = None,
    ) -> None:

        if isinstance(arbitrary_number, int) or isinstance(arbitrary_number, float):
            self.arbitrary_number = arbitrary_number
        else:
            raise ValueError("arbitrary_number must be numeric of type int or float")

        self.variables = _check_input_parameter_variables(variables)

        self.imputer_dict = _define_numerical_dict(imputer_dict)
Esempio n. 4
0
def test_numerical_dict():
    input_dict = {"a": 1, "b": 2}
    expected_output = {"a": 1, "b": 2}

    assert _define_numerical_dict(input_dict) == expected_output
Esempio n. 5
0
def test_input_type():
    input_dict = [1, 2, 3]

    with pytest.raises(TypeError):
        assert _define_numerical_dict(input_dict)
Esempio n. 6
0
def test_not_numerical_dict():
    input_dict = {"a": 1, "b": "c"}

    with pytest.raises(ValueError):
        assert _define_numerical_dict(input_dict)