Skip to content

reconstructed_total division by zero #2

@clawfire

Description

@clawfire

Prerequisites

  • Reproduced the problem or exposed a new need
  • Checked the github existing issues

Description

Running the prediction.py script provided here I ran into a divided by zero error on a specific document.

Steps to Reproduce

  1. Copy the first exemple code of the performances-benchmark tuto (see link before)
  2. Run the code against specific files
  3. See the divided by zero error

Expected behavior:

Parse the document and provide json

Actual behavior:

Parse the document, get prediction and crash at reconstruction step reconstructed_total += tax.value + 100 * tax.value / tax.rate

Reproduces how often:

100% of the time on that specific file

Versions

latest mindee-api-python code available

Additional Information

Stack trance:

[REDACTED] factures TVA novembre 2006-page15.pdf float division by zero
Traceback (most recent call last):
  File "prediction.py", line 13, in <module>
    mindee_response = mindee_client.parse_invoice(test_file_path)
  File "/home/pafer/.local/share/virtualenvs/mindee-wRBzjoc1/lib/python3.8/site-packages/mindee/__init__.py", line 180, in parse_invoice
    return self._wrap_response(input_file, response, "invoice")
  File "/home/pafer/.local/share/virtualenvs/mindee-wRBzjoc1/lib/python3.8/site-packages/mindee/__init__.py", line 93, in _wrap_response
    return Response.format_response(dict_response, document_type, input_file)
  File "/home/pafer/.local/share/virtualenvs/mindee-wRBzjoc1/lib/python3.8/site-packages/mindee/__init__.py", line 302, in format_response
    Invoice(
  File "/home/pafer/.local/share/virtualenvs/mindee-wRBzjoc1/lib/python3.8/site-packages/mindee/documents/invoice.py", line 91, in __init__
    self._checklist()
  File "/home/pafer/.local/share/virtualenvs/mindee-wRBzjoc1/lib/python3.8/site-packages/mindee/documents/invoice.py", line 192, in _checklist
    "taxes_match_total_incl": self.__taxes_match_total_incl(),
  File "/home/pafer/.local/share/virtualenvs/mindee-wRBzjoc1/lib/python3.8/site-packages/mindee/documents/invoice.py", line 212, in __taxes_match_total_incl
    reconstructed_total += tax.value + 100 * tax.value / tax.rate
ZeroDivisionError: float division by zero
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "prediction.py", line 18, in <module>
    print(e.with_traceback())
TypeError: with_traceback() takes exactly one argument (0 given)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions