fontMath icon indicating copy to clipboard operation
fontMath copied to clipboard

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

Open anthrotype opened this issue 7 years ago • 5 comments

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.")

anthrotype avatar Nov 01 '16 12:11 anthrotype

@typesupply I'm going to temporarily disable this test, as it risks making the whole CI build fail in random fashion (not nice while you're tagging a release). Could you have a look at some point? I don't understand the purpose of this test... Thank you.

anthrotype avatar Jan 27 '17 16:01 anthrotype

I don't know anything about this functionality. Sorry. I think @letterror added it here: https://github.com/typesupply/fontMath/commit/4a1f0fcbd2cde660dc5baaebbcea35189490ec24 Erik, any advice?

typesupply avatar Jan 27 '17 17:01 typesupply

Ok thanks Tal.

anthrotype avatar Jan 27 '17 17:01 anthrotype

I will look at this next week, sorry.

Erik

On 27 Jan 2017, at 18:00, Tal Leming [email protected] wrote:

I don't know anything about this functionality. Sorry. I think @letterror added it here: 4a1f0fc Erik, any advice?

― You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

LettError avatar Jan 27 '17 17:01 LettError

I have disabled the intermittently failing test_functions test with commit https://github.com/typesupply/fontMath/commit/21b8bb80bfeb0d1d3de3457ede3574e24c13c76d.

E.g. see one recent Travis build failure caused by that: https://travis-ci.org/typesupply/fontMath/builds/279556453

I don't have the time to investigate right now. I think it's better to disable it until somebody figures out how to properly fix it.

Very low priority.

anthrotype avatar Oct 01 '17 18:10 anthrotype