Skip to content

[mathTransform] what's the purpose of test_functions unit test? #35

@anthrotype

Description

@anthrotype

It's not clear to me what the purpose of test_mathTransform.py::MathTransformTest.test_functions is.

It seems to assert that at least for some of the _testData, the three testFunctions yield slightly different results.

However:

  • only the results of the first and second functions are compared, the third seems to be ignored;
  • the assertion is too broad and catch-all: it's not very useful to know that sometimes given some random interpolation values results may be different. I would like to know when, how different and why.

Another problem is that since the interpolation value is random.random(), sometimes the test can unpredictably fail (i.e. FontMathWarning is never raised, all results are same between functions), for example:

https://travis-ci.org/typesupply/fontMath/jobs/172252357#L356

I think we need to narrow this test down a little bit, though I'm not sure how.

Maybe @typesupply or @moyogo can shed some light?

def test_functions(self):
        """
        In this test various complex transformations are interpolated using
        3 different methods:
          - straight linear interpolation, the way glyphMath does it now.
          - using the MathTransform interpolation method.
          - using the ShallowTransform with an initial decompose and final
            compose.
        """
        value = random()
        testFunctions = [
            _polarDecomposeInterpolationTransformation,
            _mathPolarDecomposeInterpolationTransformation,
            _linearInterpolationTransformMatrix,
        ]
        with self.assertRaisesRegex(
                FontMathWarning,
                "Minor differences occured when "
                "comparing the interpolation functions."):
            for i, m in enumerate(_testData):
                m1, m2 = m
                results = []
                for func in testFunctions:
                    r = func(m1, m2, value)
                    results.append(r)
                if not results[0] == results[1]:
                    raise FontMathWarning(
                        "Minor differences occured when "
                        "comparing the interpolation functions.")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions