Closed hroncok closed 6 years ago
mesh.vectors when created:
[[[0. 1. 1.]
[1. 0. 1.]
[0. 0. 1.]]
[[1. 0. 1.]
[0. 1. 1.]
[1. 1. 1.]]
[[1. 0. 0.]
[1. 0. 1.]
[1. 1. 0.]]
[[1. 1. 1.]
[1. 0. 1.]
[1. 1. 0.]]
[[0. 0. 0.]
[1. 0. 0.]
[1. 0. 1.]]
[[0. 0. 0.]
[0. 0. 1.]
[1. 0. 1.]]]
mesh.vectors after -= .5:
[[[-0.5 0.5 0.5]
[ 0.5 -0.5 0.5]
[-0.5 -0.5 0.5]]
[[ 0.5 -0.5 0.5]
[-0.5 0.5 0.5]
[ 0.5 0.5 0.5]]
[[ 0.5 -0.5 -0.5]
[ 0.5 -0.5 0.5]
[ 0.5 0.5 -0.5]]
[[ 0.5 0.5 0.5]
[ 0.5 -0.5 0.5]
[ 0.5 0.5 -0.5]]
[[-0.5 -0.5 -0.5]
[ 0.5 -0.5 -0.5]
[ 0.5 -0.5 0.5]]
[[-0.5 -0.5 -0.5]
[-0.5 -0.5 0.5]
[ 0.5 -0.5 0.5]]]
mesh.vectors after 1st rotate:
[[[-0.5 0.5 -0.49999997]
[ 0.5 0.49999997 0.5 ]
[-0.5 0.49999997 0.5 ]]
[[ 0.5 0.49999997 0.5 ]
[-0.5 0.5 -0.49999997]
[ 0.5 0.5 -0.49999997]]
[[ 0.5 -0.5 0.49999997]
[ 0.5 0.49999997 0.5 ]
[ 0.5 -0.49999997 -0.5 ]]
[[ 0.5 0.5 -0.49999997]
[ 0.5 0.49999997 0.5 ]
[ 0.5 -0.49999997 -0.5 ]]
[[-0.5 -0.5 0.49999997]
[ 0.5 -0.5 0.49999997]
[ 0.5 0.49999997 0.5 ]]
[[-0.5 -0.5 0.49999997]
[-0.5 0.49999997 0.5 ]
[ 0.5 0.49999997 0.5 ]]]
mesh.vectors after 2nd rotate:
[[[ 0.49999994 0.5 -0.5 ]
[-0.49999997 0.49999997 0.5 ]
[-0.5 0.49999997 -0.49999997]]
[[-0.49999997 0.49999997 0.5 ]
[ 0.49999994 0.5 -0.5 ]
[ 0.49999997 0.5 0.49999997]]
[[-0.49999994 -0.5 0.5 ]
[-0.49999997 0.49999997 0.5 ]
[ 0.5 -0.49999997 0.49999997]]
[[ 0.49999997 0.5 0.49999997]
[-0.49999997 0.49999997 0.5 ]
[ 0.5 -0.49999997 0.49999997]]
[[-0.49999997 -0.5 -0.49999997]
[-0.49999994 -0.5 0.5 ]
[-0.49999997 0.49999997 0.5 ]]
[[-0.49999997 -0.5 -0.49999997]
[-0.5 0.49999997 -0.49999997]
[-0.49999997 0.49999997 0.5 ]]]
mesh.vectors after 3rd rotate:
[[[ 0.49999994 -0.49999997 -0.5 ]
[-0.49999997 0.5 -0.49999994]
[-0.5 -0.49999994 -0.49999997]]
[[-0.49999997 0.5 -0.49999994]
[ 0.49999994 -0.49999997 -0.5 ]
[ 0.49999997 0.49999997 -0.49999997]]
[[-0.49999994 0.49999997 0.5 ]
[-0.49999997 0.5 -0.49999994]
[ 0.5 0.49999994 0.49999997]]
[[ 0.49999997 0.49999997 -0.49999997]
[-0.49999997 0.5 -0.49999994]
[ 0.5 0.49999994 0.49999997]]
[[-0.49999997 -0.49999997 0.49999997]
[-0.49999994 0.49999997 0.5 ]
[-0.49999997 0.5 -0.49999994]]
[[-0.49999997 -0.49999997 0.49999997]
[-0.5 -0.49999994 -0.49999997]
[-0.49999997 0.5 -0.49999994]]]
mesh.vectors after += .5:
[[[9.9999994e-01 2.9802322e-08 0.0000000e+00]
[2.9802322e-08 1.0000000e+00 5.9604645e-08]
[0.0000000e+00 5.9604645e-08 2.9802322e-08]]
[[2.9802322e-08 1.0000000e+00 5.9604645e-08]
[9.9999994e-01 2.9802322e-08 0.0000000e+00]
[1.0000000e+00 1.0000000e+00 2.9802322e-08]]
[[5.9604645e-08 1.0000000e+00 1.0000000e+00]
[2.9802322e-08 1.0000000e+00 5.9604645e-08]
[1.0000000e+00 9.9999994e-01 1.0000000e+00]]
[[1.0000000e+00 1.0000000e+00 2.9802322e-08]
[2.9802322e-08 1.0000000e+00 5.9604645e-08]
[1.0000000e+00 9.9999994e-01 1.0000000e+00]]
[[2.9802322e-08 2.9802322e-08 1.0000000e+00]
[5.9604645e-08 1.0000000e+00 1.0000000e+00]
[2.9802322e-08 1.0000000e+00 5.9604645e-08]]
[[2.9802322e-08 2.9802322e-08 1.0000000e+00]
[0.0000000e+00 5.9604645e-08 2.9802322e-08]
[2.9802322e-08 1.0000000e+00 5.9604645e-08]]]
Well... I wouldn't really call it broken, this is simply the result of floating point inaccuracy. The test is just a bit too strict and doesn't account for floating point inaccuracies.
Apparently the ppc64le platform uses a slightly different floating point implementation within numpy. It might be related to this: https://github.com/numpy/numpy/issues/10281
Since I don't have access to a ppc64le machine I can't easily fix this (or at least, not test it) but something like this might do the trick:
assert (mesh.vectors - numpy.array([
[[1, 0, 0], [0, 1, 0], [0, 0, 0]],
[[0, 1, 0], [1, 0, 0], [1, 1, 0]],
[[0, 1, 1], [0, 1, 0], [1, 1, 1]],
[[1, 1, 0], [0, 1, 0], [1, 1, 1]],
[[0, 0, 1], [0, 1, 1], [0, 1, 0]],
[[0, 0, 1], [0, 0, 0], [0, 1, 0]],
])).sum() < 0.0001
I'm playing with numpy.isclose to check if the result is close :)
Didn't know of the existence of numpy.isclose
but that would be a great solution for all tests I think :)
numpy.allclose
is another option
numpy.allclose(a, b, atol=1e-07)
seems to do the job, will prep a PR
@WoLpH, @Uvar: Thank you both!
I'm not familiar with ppc64le that much, but apparently something is broken here:
I'll try to see at what point the result is wrong.