Skip to content

Instantly share code, notes, and snippets.

@alexgorban
alexgorban / assert_almost_equal_answer.txt
Last active December 15, 2017 23:35
Debugging broken tests can be very tricky
Can you spot a problem in the code?
np.testing.assert_almost_equal(A, B, decimal=7)
Error log:
-------------------------------------------------------------------------------
AssertionError:
Arrays are not almost equal to 7 decimals
(mismatch 18.75%)
"""Illustration for various types of namespace scopes in TensorFlow.
> python tf_scopes.py
foo_name_scoped :
v.name= v:0
v2.name= foo_name_scoped/v2:0
a.name= Variable:0
b.name= Variable_1:0
result_op.name= foo_name_scoped/Add:0
foo_op_scoped :
// Simple tool to store all integers which are missing in the float representation.
//
// Missing means here that if you convert integer into float and then back into
// integer you will not get the same integer. This experiment reveals that for
// 96.5% of all integers n != int(float(n))
//
// It appears that missing integers go in blocks of length 2, 6, 14, 30, 62
// and 126 of consecutive numbers (8388608 blocks of each type).
// And there is one single integer -33554431 who stands apart.
//