tests#

unit tests#

ExtTestCase#

class onnxrt_backend_dev.ext_test_case.ExtTestCase(methodName='runTest')[source]#
assertAlmostEqual(expected: ndarray, value: ndarray, atol: float = 0, rtol: float = 0)[source]#

Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the difference between the two objects is more than the given delta.

Note that decimal places (from zero) are usually not the same as significant digits (measured from the most significant digit).

If the two objects compare equal then they will automatically compare almost equal.

capture(fct: Callable)[source]#

Runs a function and capture standard output and error.

Parameters:

fct – function to run

Returns:

result of fct, output, error

classmethod tearDownClass()[source]#

Hook method for deconstructing the class fixture after running all tests in the class.

tryCall(fct: Callable, msg: str | None = None, none_if: str | None = None) Any | None[source]#

Calls the function, catch any error.

Parameters:
  • fct – function to call

  • msg – error message to display if failing

  • none_if – returns None if this substring is found in the error message

Returns:

output of fct

command line#

get_parsed_args#

onnxrt_backend_dev.args.get_parsed_args(name: str, scenarios: Dict[str, str] | None = None, description: str | None = None, epilog: str | None = None, number: int = 10, repeat: int = 10, warmup: int = 5, sleep: float = 0.1, tries: int = 2, expose: str | None = None, args: List[str] | None = None, **kwargs) Namespace[source]#

Returns parsed arguments for examples in this package.

Parameters:
  • name – script name

  • scenarios – list of available scenarios

  • description – parser description

  • epilog – text at the end of the parser

  • number – default value for number parameter

  • repeat – default value for repeat parameter

  • warmup – default value for warmup parameter

  • sleep – default value for sleep parameter

  • expose – if empty, keeps all the parameters, if None, only publish kwargs contains, otherwise the list of parameters to publish separated by a comma

  • args – or sys.args if empty

  • kwargs – additional parameters, example: n_trees=(10, “number of trees to train”)

Returns:

parser