cleanup exceptions
This commit is contained in:
parent
d14bb6819f
commit
a53c125d95
|
@ -5,14 +5,14 @@ Changelog
|
|||
^^^^^^^^^^^^^^^^^^^^
|
||||
Fixed
|
||||
~~~~~
|
||||
* use the correct version of `rapidfuzz-cpp` when building against a system installed version
|
||||
* use the correct version of ``rapidfuzz-cpp`` when building against a system installed version
|
||||
|
||||
|
||||
[3.8.0] - 2024-04-06
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
Added
|
||||
~~~~~
|
||||
* added ``process.cpdist`` which allows pairwise comparision of two collection of inputs
|
||||
* added ``process.cpdist`` which allows pairwise comparison of two collection of inputs
|
||||
|
||||
Fixed
|
||||
~~~~~
|
||||
|
|
|
@ -60,7 +60,8 @@ def similarity(
|
|||
score_cutoff = 0
|
||||
|
||||
if prefix_weight > 1.0 or prefix_weight < 0.0:
|
||||
raise ValueError("prefix_weight has to be in the range 0.0 - 1.0")
|
||||
msg = "prefix_weight has to be in the range 0.0 - 1.0"
|
||||
raise ValueError(msg)
|
||||
|
||||
s1, s2 = conv_sequences(s1, s2)
|
||||
P_len = len(s1)
|
||||
|
|
|
@ -948,7 +948,8 @@ def jaro_winkler_distance(s1, s2, *, double prefix_weight=0.1, processor=None, s
|
|||
return 1.0
|
||||
|
||||
if prefix_weight > 1.0 or prefix_weight < 0.0:
|
||||
raise ValueError("prefix_weight has to be in the range 0.0 - 1.0")
|
||||
msg = "prefix_weight has to be in the range 0.0 - 1.0"
|
||||
raise ValueError(msg)
|
||||
|
||||
cdef double c_score_cutoff = get_score_cutoff_f64(score_cutoff, 1.0, 0.0)
|
||||
preprocess_strings(s1, s2, processor, &s1_proc, &s2_proc)
|
||||
|
@ -961,7 +962,8 @@ def jaro_winkler_similarity(s1, s2, *, double prefix_weight=0.1, processor=None,
|
|||
return 0.0
|
||||
|
||||
if prefix_weight > 1.0 or prefix_weight < 0.0:
|
||||
raise ValueError("prefix_weight has to be in the range 0.0 - 1.0")
|
||||
msg = "prefix_weight has to be in the range 0.0 - 1.0"
|
||||
raise ValueError(msg)
|
||||
|
||||
cdef double c_score_cutoff = get_score_cutoff_f64(score_cutoff, 0.0, 1.0)
|
||||
preprocess_strings(s1, s2, processor, &s1_proc, &s2_proc)
|
||||
|
@ -974,7 +976,8 @@ def jaro_winkler_normalized_distance(s1, s2, *, double prefix_weight=0.1, proces
|
|||
return 1.0
|
||||
|
||||
if prefix_weight > 1.0 or prefix_weight < 0.0:
|
||||
raise ValueError("prefix_weight has to be in the range 0.0 - 1.0")
|
||||
msg = "prefix_weight has to be in the range 0.0 - 1.0"
|
||||
raise ValueError(msg)
|
||||
|
||||
cdef double c_score_cutoff = get_score_cutoff_f64(score_cutoff, 1.0, 0.0)
|
||||
preprocess_strings(s1, s2, processor, &s1_proc, &s2_proc)
|
||||
|
@ -987,7 +990,8 @@ def jaro_winkler_normalized_similarity(s1, s2, *, double prefix_weight=0.1, proc
|
|||
return 0.0
|
||||
|
||||
if prefix_weight > 1.0 or prefix_weight < 0.0:
|
||||
raise ValueError("prefix_weight has to be in the range 0.0 - 1.0")
|
||||
msg = "prefix_weight has to be in the range 0.0 - 1.0"
|
||||
raise ValueError(msg)
|
||||
|
||||
cdef double c_score_cutoff = get_score_cutoff_f64(score_cutoff, 0.0, 1.0)
|
||||
preprocess_strings(s1, s2, processor, &s1_proc, &s2_proc)
|
||||
|
@ -1002,7 +1006,8 @@ cdef bool JaroWinklerKwargsInit(RF_Kwargs * self, dict kwargs) except False:
|
|||
prefix_weight[0] = kwargs.get("prefix_weight", 0.1)
|
||||
if prefix_weight[0] > 1.0 or prefix_weight[0] < 0.0:
|
||||
free(prefix_weight)
|
||||
raise ValueError("prefix_weight has to be in the range 0.0 - 1.0")
|
||||
msg = "prefix_weight has to be in the range 0.0 - 1.0"
|
||||
raise ValueError(msg)
|
||||
|
||||
self.context = prefix_weight
|
||||
self.dtor = KwargsDeinit
|
||||
|
|
|
@ -9,16 +9,19 @@ from tests.distance.common import JaroWinkler
|
|||
def test_hash_special_case():
|
||||
assert pytest.approx(JaroWinkler.similarity([0, -1], [0, -2])) == 0.666666
|
||||
|
||||
|
||||
def test_large_prefix_weight():
|
||||
assert pytest.approx(JaroWinkler.similarity('milyarder', 'milyarderlik',prefix_weight=0.5)) == 1.0
|
||||
assert pytest.approx(JaroWinkler.similarity('milyarder', 'milyarderlik',prefix_weight=1.0)) == 1.0
|
||||
assert pytest.approx(JaroWinkler.similarity("milyarder", "milyarderlik", prefix_weight=0.5)) == 1.0
|
||||
assert pytest.approx(JaroWinkler.similarity("milyarder", "milyarderlik", prefix_weight=1.0)) == 1.0
|
||||
|
||||
|
||||
def test_invalid_prefix_weight():
|
||||
with pytest.raises(ValueError, match="prefix_weight has to be in the range 0.0 - 1.0"):
|
||||
JaroWinkler.similarity('milyarder', 'milyarderlik',prefix_weight=-0.1)
|
||||
JaroWinkler.similarity("milyarder", "milyarderlik", prefix_weight=-0.1)
|
||||
|
||||
with pytest.raises(ValueError, match="prefix_weight has to be in the range 0.0 - 1.0"):
|
||||
JaroWinkler.similarity('milyarder', 'milyarderlik',prefix_weight=1.1)
|
||||
JaroWinkler.similarity("milyarder", "milyarderlik", prefix_weight=1.1)
|
||||
|
||||
|
||||
def test_edge_case_lengths():
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue