Repository: dirty-cat/dirty_cat (python)

Issue:
Make fuzzy_join's match_score error more explicit
<!--Provide a brief description of the bug.-->
It happened to me recently that I made an error when specifying the `match_score` parameter.

The error got me confused, maybe it should be made more explicit when the parameter type is invalid.

<!--Please fill in the following information, to the best of your ability.-->

Steps and code to reproduce the bug:

```python
>>> import pandas as pd
>>> from dirty_cat import fuzzy_join
>>> df1 = pd.DataFrame({'a': ['ana', 'lala', 'nana'], 'b': [1, 2, 3]})
>>> df2 = pd.DataFrame({'a': ['anna', 'lala', 'ana', 'nnana'], 'c': [5, 6, 7, 8]})

>>> fuzzy_join(df1, df2, on="a", match_distance='string')

    main_table.loc[np.ravel(match_distance < distance), "fj_nan"] = 1
TypeError: '<' not supported between instances of 'str' and 'numpy.ndarray'
```


Pull request description:
FIX Error when wrong type of fuzzy_join parameter
Fix #533
and one small type of error change.

Patch:
diff --git a/dirty_cat/_fuzzy_join.py b/dirty_cat/_fuzzy_join.py
index 8b37446..1d1a43d 100644
--- a/dirty_cat/_fuzzy_join.py
+++ b/dirty_cat/_fuzzy_join.py
@@ -187,9 +187,12 @@ def fuzzy_join(
             f"how should be either 'left' or 'right', got {how!r}",
         )
 
+    if not isinstance(match_score, (int, float)):
+        raise TypeError("match_score has invalid type, expected integer or float")
+
     for param in [on, left_on, right_on]:
         if param is not None and not isinstance(param, str):
-            raise KeyError(
+            raise TypeError(
                 "Parameter 'left_on', 'right_on' or 'on' has invalid type, expected"
                 " string"
             )
diff --git a/dirty_cat/_similarity_encoder.py b/dirty_cat/_similarity_encoder.py
index 09e0ad6..d2067e6 100644
--- a/dirty_cat/_similarity_encoder.py
+++ b/dirty_cat/_similarity_encoder.py
@@ -519,9 +519,12 @@ class SimilarityEncoder(OneHotEncoder):
                 ]
             )
 
-        self.drop_idx_ = self._compute_drop_idx()
         if parse_version(sklearn.__version__) >= parse_version("1.1.0"):
             self._infrequent_enabled = False
+        if parse_version(sklearn.__version__) >= parse_version("1.2.0"):
+            self.drop_idx_ = self._set_drop_idx()
+        else:
+            self.drop_idx_ = self._compute_drop_idx()
 
         return self
 


Test patch:
diff --git a/dirty_cat/tests/test_fuzzy_join.py b/dirty_cat/tests/test_fuzzy_join.py
index 4401254..bf60a7c 100644
--- a/dirty_cat/tests/test_fuzzy_join.py
+++ b/dirty_cat/tests/test_fuzzy_join.py
@@ -100,10 +100,15 @@ def test_parameters_error(analyzer, on, how):
     ):
         fuzzy_join(df1, df2, on="a", analyzer=analyzer, how=how)
     with pytest.raises(
-        KeyError,
+        TypeError,
         match=r"invalid type",
     ):
         fuzzy_join(df1, df2, on=on, how=how)
+    with pytest.raises(
+        TypeError,
+        match=r"invalid type",
+    ):
+        fuzzy_join(df1, df2, on="a", match_score="blabla")
 
 
 def test_missing_keys():