Skip to content

Commit

Permalink
fix pure Python fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbachmann committed Jul 30, 2022
1 parent 93b0124 commit 2412e57
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

### [2.4.2] - 2022-07-30
#### Fixed
- add missing symbol to pure Python which made the usage impossible

### [2.4.1] - 2022-07-29
#### Fixed
- fix version number
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'Max Bachmann'

# The full version, including alpha/beta/rc tags
release = '2.4.1'
release = '2.4.2'


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def show_message(*lines):

setup_args = {
"name": "rapidfuzz",
"version": "2.4.1",
"version": "2.4.2",
"install_requires": ["jarowinkler >= 1.2.0, < 2.0.0"],
"extras_require": {'full': ['numpy']},
"url": "https://github.com/maxbachmann/RapidFuzz",
Expand Down
2 changes: 1 addition & 1 deletion src/rapidfuzz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"""
__author__: str = "Max Bachmann"
__license__: str = "MIT"
__version__: str = "2.4.1"
__version__: str = "2.4.2"

from rapidfuzz import process, distance, fuzz, string_metric, utils
26 changes: 26 additions & 0 deletions src/rapidfuzz/distance/_initialize_py.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
# SPDX-License-Identifier: MIT
# Copyright (C) 2022 Max Bachmann

class MatchingBlock:
def __init__(self, a, b, size):
self.a = a
self.b = b
self.size = size

def __len__(self):
return 3

def __eq__(self, other):
if len(other) != 3:
return False

return (other[0] == self.a
and other[1] == self.b
and other[2] == self.size)

def __getitem__(self, i):
if i==0 or i==-3: return self.a
if i==1 or i==-2: return self.b
if i==2 or i==-1: return self.size

raise IndexError('MatchingBlock index out of range')

def __repr__(self):
return f"MatchingBlock(a={self.a}, b={self.b}, size={self.size})"

class Editop:
"""
Expand Down
4 changes: 4 additions & 0 deletions tests/test_cpp_fallback.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# simple test to ensure the C++ version is not missing any symbols
import os
os.environ["RAPIDFUZZ_IMPLEMENTATION"] = "cpp"
import rapidfuzz
4 changes: 4 additions & 0 deletions tests/test_pure_python_fallback.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# simple test to ensure the pure Python version is not missing any symbols
import os
os.environ["RAPIDFUZZ_IMPLEMENTATION"] = "python"
import rapidfuzz

0 comments on commit 2412e57

Please sign in to comment.