Skip to content

Commit 1b72757

Browse files
ianardeeixunio
authored andcommitted
chg: 💥 remove matplotlib and associated benchmark functions
1 parent 0cdd58c commit 1b72757

File tree

14 files changed

+14
-362
lines changed

14 files changed

+14
-362
lines changed

.github/workflows/linting.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: ["3.9"]
11+
python-version: ["3.8"]
1212
steps:
1313
- uses: actions/checkout@v2
1414
- name: Set up Python ${{ matrix.python-version }}
1515
uses: actions/setup-python@v2
1616
with:
1717
python-version: ${{ matrix.python-version }}
1818
- name: Install dependencies
19+
# We install the full dev requirements to make sure everything installs OK
1920
run: |
2021
python -m pip install pip
21-
pip install black==21.12b0
22+
pip install --requirement ./requirements.dev.txt
2223
- name: Analysing the code with Black
2324
run: |
2425
black --check ./mindee

.github/workflows/test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
matrix:
1212
python-version:
1313
#- "3.5"
14-
#- "3.6"
14+
- "3.6"
1515
- "3.7"
1616
- "3.8"
1717
- "3.9"
@@ -35,8 +35,9 @@ jobs:
3535
- name: Install dependencies
3636
run: |
3737
python -m pip install pip
38-
pip install --requirement ./requirements.dev.txt
38+
pip install pytest~=6.1.2 pytest-cov~=2.11.1 wheel
39+
pip install --requirement ./requirements.txt
3940
4041
- name: Testing the code with pytest
4142
run: |
42-
pytest .
43+
pytest

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
The full documentation is available [here](https://developers.mindee.com/docs/getting-started)
44

5+
## Requirements
6+
7+
This library is compatible with Python 3.5 and above.
8+
59
## Install
610

711
Install from PyPi using pip, a package manager for Python.

mindee/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from mindee.documents.financial_document import FinancialDocument
99
from mindee.documents.invoice import Invoice
1010
from mindee.documents.passport import Passport
11-
from mindee.benchmark import Benchmark
1211

1312
DOCUMENT_CLASSES = {
1413
"receipt": Receipt,

mindee/benchmark.py

Lines changed: 0 additions & 98 deletions
This file was deleted.

mindee/documents/financial_document.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from mindee.benchmark import Benchmark
2-
31
from mindee.fields.amount import Amount
42
from mindee.fields.date import Date
53
from mindee.fields.locale import Locale
@@ -206,11 +204,6 @@ def compare(financial_document=None, ground_truth=None):
206204
FinancialDocument.compute_accuracy(financial_document, ground_truth)
207205
)
208206

209-
# Compute precision metrics
210-
metrics.update(
211-
FinancialDocument.compute_precision(financial_document, ground_truth)
212-
)
213-
214207
return metrics
215208

216209
@staticmethod
@@ -301,40 +294,3 @@ def compute_accuracy(financial_document, ground_truth):
301294
financial_document.taxes, ground_truth.taxes
302295
),
303296
}
304-
305-
@staticmethod
306-
def compute_precision(financial_document, ground_truth):
307-
"""
308-
:param financial_document: FinancialDocument object to compare
309-
:param ground_truth: Ground truth FinancialDocument object
310-
:return: Precision metrics
311-
"""
312-
precisions = {
313-
"__pre__total_incl": Benchmark.scalar_precision_score(
314-
financial_document.total_incl, ground_truth.total_incl
315-
),
316-
"__pre__total_excl": Benchmark.scalar_precision_score(
317-
financial_document.total_excl, ground_truth.total_excl
318-
),
319-
"__pre__invoice_date": Benchmark.scalar_precision_score(
320-
financial_document.date, ground_truth.date
321-
),
322-
"__pre__invoice_number": Benchmark.scalar_precision_score(
323-
financial_document.invoice_number, ground_truth.invoice_number
324-
),
325-
"__pre__due_date": Benchmark.scalar_precision_score(
326-
financial_document.due_date, ground_truth.due_date
327-
),
328-
"__pre__total_tax": Benchmark.scalar_precision_score(
329-
financial_document.total_tax, ground_truth.total_tax
330-
),
331-
}
332-
333-
if len(financial_document.taxes) == 0:
334-
precisions["__pre__taxes"] = None
335-
else:
336-
precisions["__pre__taxes"] = Tax.compare_arrays(
337-
financial_document.taxes, ground_truth.taxes
338-
)
339-
340-
return precisions

mindee/documents/invoice.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from mindee.fields.payment_details import PaymentDetails
88
from mindee.fields.tax import Tax
99
from mindee.http import request
10-
from mindee.benchmark import Benchmark
1110
import os
1211

1312

@@ -197,9 +196,6 @@ def compare(invoice=None, ground_truth=None):
197196
# Compute Accuracy metrics
198197
metrics.update(Invoice.compute_accuracy(invoice, ground_truth))
199198

200-
# Compute precision metrics
201-
metrics.update(Invoice.compute_precision(invoice, ground_truth))
202-
203199
return metrics
204200

205201
@staticmethod
@@ -460,40 +456,3 @@ def compute_accuracy(invoice, ground_truth):
460456
"__acc__total_tax": ground_truth.total_tax == invoice.total_tax,
461457
"__acc__taxes": Tax.compare_arrays(invoice.taxes, ground_truth.taxes),
462458
}
463-
464-
@staticmethod
465-
def compute_precision(invoice, ground_truth):
466-
"""
467-
:param invoice: Invoice object to compare
468-
:param ground_truth: Ground truth Invoice object
469-
:return: Precision metrics
470-
"""
471-
precisions = {
472-
"__pre__total_incl": Benchmark.scalar_precision_score(
473-
invoice.total_incl, ground_truth.total_incl
474-
),
475-
"__pre__total_excl": Benchmark.scalar_precision_score(
476-
invoice.total_excl, ground_truth.total_excl
477-
),
478-
"__pre__invoice_date": Benchmark.scalar_precision_score(
479-
invoice.invoice_date, ground_truth.invoice_date
480-
),
481-
"__pre__invoice_number": Benchmark.scalar_precision_score(
482-
invoice.invoice_number, ground_truth.invoice_number
483-
),
484-
"__pre__due_date": Benchmark.scalar_precision_score(
485-
invoice.due_date, ground_truth.due_date
486-
),
487-
"__pre__total_tax": Benchmark.scalar_precision_score(
488-
invoice.total_tax, ground_truth.total_tax
489-
),
490-
}
491-
492-
if len(invoice.taxes) == 0:
493-
precisions["__pre__taxes"] = None
494-
else:
495-
precisions["__pre__taxes"] = Tax.compare_arrays(
496-
invoice.taxes, ground_truth.taxes
497-
)
498-
499-
return precisions

mindee/documents/passport.py

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from mindee.benchmark import Benchmark
21
from mindee.documents import Document
32
from mindee.fields import Field
43
from mindee.fields.date import Date
@@ -182,9 +181,6 @@ def compare(passport=None, ground_truth=None):
182181
# Compute Accuracy metrics
183182
metrics.update(Passport.compute_accuracy(passport, ground_truth))
184183

185-
# Compute precision metrics
186-
metrics.update(Passport.compute_precision(passport, ground_truth))
187-
188184
return metrics
189185

190186
def is_expired(self):
@@ -377,55 +373,3 @@ def compute_accuracy(passport, ground_truth):
377373
"__acc__mrz": ground_truth.mrz == passport.mrz,
378374
"__acc__full_name": ground_truth.full_name == passport.full_name,
379375
}
380-
381-
@staticmethod
382-
def compute_precision(passport, ground_truth):
383-
"""
384-
:param passport: Passport object to compare
385-
:param ground_truth: Ground truth Passport object
386-
:return: Precision metrics
387-
"""
388-
precisions = {
389-
"__pre__country": Benchmark.scalar_precision_score(
390-
passport.country, ground_truth.country
391-
),
392-
"__pre__id_number": Benchmark.scalar_precision_score(
393-
passport.id_number, ground_truth.id_number
394-
),
395-
"__pre__birth_date": Benchmark.scalar_precision_score(
396-
passport.birth_date, ground_truth.birth_date
397-
),
398-
"__pre__expiry_date": Benchmark.scalar_precision_score(
399-
passport.expiry_date, ground_truth.expiry_date
400-
),
401-
"__pre__issuance_date": Benchmark.scalar_precision_score(
402-
passport.issuance_date, ground_truth.issuance_date
403-
),
404-
"__pre__gender": Benchmark.scalar_precision_score(
405-
passport.gender, ground_truth.gender
406-
),
407-
"__pre__surname": Benchmark.scalar_precision_score(
408-
passport.surname, ground_truth.surname
409-
),
410-
"__pre__mrz1": Benchmark.scalar_precision_score(
411-
passport.mrz1, ground_truth.mrz1
412-
),
413-
"__pre__mrz2": Benchmark.scalar_precision_score(
414-
passport.mrz2, ground_truth.mrz2
415-
),
416-
"__pre__mrz": Benchmark.scalar_precision_score(
417-
passport.mrz, ground_truth.mrz
418-
),
419-
"__pre__full_name": Benchmark.scalar_precision_score(
420-
passport.full_name, ground_truth.full_name
421-
),
422-
}
423-
424-
if len(passport.given_names) == 0:
425-
precisions["__pre__given_names"] = None
426-
else:
427-
precisions["__pre__given_names"] = Field.compare_arrays(
428-
passport.given_names, ground_truth.given_names
429-
)
430-
431-
return precisions

mindee/documents/receipt.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from mindee.benchmark import Benchmark
21
from mindee.documents import Document
32
from mindee.fields import Field
43
from mindee.fields.date import Date
@@ -172,9 +171,6 @@ def compare(receipt=None, ground_truth=None):
172171
# Compute Accuracy metrics
173172
metrics.update(Receipt.compute_accuracy(receipt, ground_truth))
174173

175-
# Compute precision metrics
176-
metrics.update(Receipt.compute_precision(receipt, ground_truth))
177-
178174
return metrics
179175

180176
@staticmethod
@@ -295,34 +291,3 @@ def compute_accuracy(receipt, ground_truth):
295291
"__acc__total_tax": ground_truth.total_tax == receipt.total_tax,
296292
"__acc__taxes": Tax.compare_arrays(receipt.taxes, ground_truth.taxes),
297293
}
298-
299-
@staticmethod
300-
def compute_precision(receipt, ground_truth):
301-
"""
302-
:param receipt: Receipt object to compare
303-
:param ground_truth: Ground truth Receipt object
304-
:return: Precision metrics
305-
"""
306-
precisions = {
307-
"__pre__total_incl": Benchmark.scalar_precision_score(
308-
receipt.total_incl, ground_truth.total_incl
309-
),
310-
"__pre__total_excl": Benchmark.scalar_precision_score(
311-
receipt.total_excl, ground_truth.total_excl
312-
),
313-
"__pre__receipt_date": Benchmark.scalar_precision_score(
314-
receipt.date, ground_truth.date
315-
),
316-
"__pre__total_tax": Benchmark.scalar_precision_score(
317-
receipt.total_tax, ground_truth.total_tax
318-
),
319-
}
320-
321-
if len(receipt.taxes) == 0:
322-
precisions["__pre__taxes"] = None
323-
else:
324-
precisions["__pre__taxes"] = Tax.compare_arrays(
325-
receipt.taxes, ground_truth.taxes
326-
)
327-
328-
return precisions

0 commit comments

Comments
 (0)