astheeggeggs / lshmm

code to run Li and Stephens
MIT License
3 stars 3 forks source link

Scale mutation rate for the diploid case and add tests #61

Closed szhan closed 1 month ago

szhan commented 1 month ago

Fix #39

szhan commented 1 month ago

I am still getting a few assertion fails for the test_ts_simple_n8 tests. They are caused by high relative differences but tiny absolute differences between log-likelihood values and FB product matrix values.

For example:

E           AssertionError: 
E           Not equal to tolerance rtol=1e-09, atol=0
E           
E           Mismatched elements: 1 / 1 (100%)
E           Max absolute difference: 8.19678347e-16
E           Max relative difference: 1.88888889
E            x: array(-1.253626e-15)
E            y: array(-4.339474e-16)

And

E           AssertionError: 
E           Not equal to tolerance rtol=1e-09, atol=0
E           
E           Mismatched elements: 25 / 27 (92.6%)
E           Max absolute difference: 9.64327467e-17
E           Max relative difference: 1.
E            x: array([9.643275e-17, 1.928655e-16, 1.928655e-16, 1.928655e-16,
E                  1.928655e-16, 1.928655e-16, 1.928655e-16, 1.928655e-16,
E                  1.928655e-16, 1.928655e-16, 1.928655e-16, 1.928655e-16,...
E            y: array([9.643275e-17, 9.643275e-17, 9.643275e-17, 9.643275e-17,
E                  9.643275e-17, 9.643275e-17, 9.643275e-17, 9.643275e-17,
E                  9.643275e-17, 9.643275e-17, 9.643275e-17, 9.643275e-17,...
szhan commented 1 month ago

Assert allclose at rtol=1e-09 and atol=0 may be too strict.

szhan commented 1 month ago

Perhaps we could use numpy.testing.assert_almost_equal instead. Doc here.

"The test verifies that the elements of actual and desired satisfy. abs(desired-actual) < float64(1.5 * 10**(-decimal))"

szhan commented 1 month ago

It's strange that four tests failed on my machine but passed during CI.

szhan commented 1 month ago

Not sure if this is due to architecture. I'm using Apple Silicon. I guess the workflows here use an Intel chip?