Skip to content

No longer make ExponentPrecisionType and XnorPrecisionType inherit from IntegerPrecisionType

Javier Duarte requested to merge types_inheritance into main

Created by: jmitrevs

Description

When trying to propagate precisions, isinstance(var, (IntegerPrecisionType, FixedPrecisionType)) produces incorrect results if the variable is ExponentPrecisionType or XnorPrecisionType. The "is a" requirement for inheritance is violated. Therefore it's better to remove the inheritance, which this PR does. It also cleans up a bit of the remaining string parsing there was and switches from the old % string formatting to f-strings or .format().

Type of change

It is not really a "bug" but the previous inheritance structure caused issues with yet to be added precision propagation.

  • Bug fix (non-breaking change that fixes an issue)

Tests

This should not break anything. The qkeras tests in particular are the main tests for this.

Checklist

  • I have read the guidelines for contributing.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have installed and run pre-commit on the files I edited or added.
  • I have added tests that prove my fix is effective or that my feature works.

Merge request reports

Loading