Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/_test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
MINDEE_V2_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
MINDEE_V2_SE_TESTS_BLANK_PDF_URL: ${{ secrets.MINDEE_V2_SE_TESTS_BLANK_PDF_URL }}
run: |
pytest -m integration
pytest --cov mindee -m integration


- name: Notify Slack Action on Failure
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_test-regressions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
env:
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
run: |
pytest -m regression
pytest --cov mindee -m regression

- name: Notify Slack Action on Failure
uses: ravsamhq/notify-slack-action@2.3.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_test-units.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
env:
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
run: |
pytest --cov-fail-under 87
pytest --cov mindee --cov-fail-under 87
26 changes: 26 additions & 0 deletions mindee/parsing/v2/field/field_confidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,29 @@ class FieldConfidence(str, Enum):
HIGH = "High"
MEDIUM = "Medium"
LOW = "Low"

def __int__(self) -> int:
return {"Certain": 4, "High": 3, "Medium": 2, "Low": 1}[self.value]

def __str__(self) -> str:
return self.value

def __lt__(self, other) -> bool:
if isinstance(other, FieldConfidence):
return int(self) < int(other)
raise TypeError(f"Cannot compare FieldConfidence with {type(other)}")

def __le__(self, other) -> bool:
if isinstance(other, FieldConfidence):
return int(self) <= int(other)
raise TypeError(f"Cannot compare FieldConfidence with {type(other)}")

def __gt__(self, other) -> bool:
if isinstance(other, FieldConfidence):
return int(self) > int(other)
raise TypeError(f"Cannot compare FieldConfidence with {type(other)}")

def __ge__(self, other) -> bool:
if isinstance(other, FieldConfidence):
return int(self) >= int(other)
raise TypeError(f"Cannot compare FieldConfidence with {type(other)}")
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ safe_licenses = [


[tool.pytest.ini_options]
addopts = "--pyargs --cov mindee --cov-report term:skip-covered --cov-report term-missing -m 'not regression and not integration'"
addopts = "--pyargs --cov-report term:skip-covered --cov-report term-missing -m 'not regression and not integration'"
python_files = "test*.py"
junit_family = "xunit2"
markers = [
Expand Down
9 changes: 8 additions & 1 deletion tests/v2/test_inference_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,5 +268,12 @@ def test_field_locations_and_confidence() -> None:
assert polygon[3][0] == 0.948849
assert polygon[3][1] == 0.244565

assert str(date_field.confidence) == "Medium"
assert int(date_field.confidence) == 2
assert date_field.confidence == FieldConfidence.MEDIUM
assert str(date_field.confidence.value) == "Medium"
assert date_field.confidence >= FieldConfidence.MEDIUM
assert date_field.confidence <= FieldConfidence.MEDIUM
assert date_field.confidence >= FieldConfidence.LOW
assert date_field.confidence > FieldConfidence.LOW
assert date_field.confidence <= FieldConfidence.HIGH
assert date_field.confidence < FieldConfidence.HIGH