tBuLi / symfit

Symbolic Fitting; fitting as it should be.
http://symfit.readthedocs.org
MIT License
233 stars 17 forks source link

Several failures when converting test_constrained.py to pytest #262

Open antonykamp opened 5 years ago

antonykamp commented 5 years ago

Hey, After several hours without progress, I ask you. When I convert the test "constrained" to a pytest, four tests failed. You can find the log here. The converted test are marked with _py Just some comments:

test_vector_parameter_error Two values should be going off very much, but after converting the test to a pytest, the opposite occurs.

test_constrained_dependent_on_model Here is the same problem: After converting the error occurs.

test_constrained_dependent_on_matrixmodel && test_interdependency_constrained First I got worried about these two tests, but after running the "old" unittest, it turned out that both of them also fail.

tBuLi commented 5 years ago

Hi @DuckNrOne,

Thanks for continuing the good work. Here are my suggestions:

I have the impression it might have something to do with the way unittest defines the precision, since in a statement like self.assertAlmostEqual(constr_value[0], 0.0, 10), the 10 does not quite mean 10**-10. See here for more details. If you check if the numerical answer is the same for the unittest as here, then it is no problem if you adjust the tolerance a little bit to make it work again.

One that really suprices me btw is this one for test_constrained_dependent_on_model:

>           assert constr_value[0] == pytest.approx(0.0, 1e-10)
E           assert -1.758637679927233e-11 == 0.0 ± 1.0e-12

How does the 1e-10 change to 1e-12?

I'll look at the rest in more detail later.

antonykamp commented 5 years ago

Hey @tBuLi

Thanks for your help. I'll look into the AlmostEqual-Thig with unittest and pytest. Meanwhile Meanwhile, I still want to convert the remaining tests. So it is possible that I will contact you soon ;)