File indexing completed on 2026-04-09 07:49:05
0001
0002 """
0003 lambertian_direction_cf.py
0004 ===================================
0005
0006 * HMM : TOTALLY DIFFERENT : CANNOT BE RANDOM ALIGNED
0007 * YEP, THAT WAS PILOT ERROR : PRECOOKED USAGE WAS DISABLED IN THE SCRIPT
0008
0009 * DONE : added debug to check random consumption in qsim
0010
0011 2022-04-03 16:38:05.139 INFO [4908425] [QSimTest<float>::main@614] num_default 1000000 num 1000000 type 27 ni_tranche_size 100000 print_id -1
0012 //QSim_quad_launch sim 0x703a40a00 quad 0x7042c0000 num_quad 1000000 dbg 0x703a40c00 type 27 name lambertian_direction
0013 //qsim.random_direction_marsaglia idx 0 u0 0.7402 u1 0.4385
0014 //qsim.lambertian_direction idx 0 count 1 u 0.5170
0015 //qsim.random_direction_marsaglia idx 0 u0 0.1570 u1 0.0714
0016 //qsim.random_direction_marsaglia idx 0 u0 0.4625 u1 0.2276
0017 //qsim.lambertian_direction idx 0 count 2 u 0.3294
0018
0019 * DONE: use ./rng_sequence.sh to match those randoms with the precooked sequence for idx 0
0020
0021 In [1]: seq[0]
0022 Out[1]:
0023 array([[0.74 , 0.438, 0.517, 0.157, 0.071, 0.463, 0.228, 0.329, 0.144, 0.188, 0.915, 0.54 , 0.975, 0.547, 0.653, 0.23 ],
0024 [0.339, 0.761, 0.546, 0.97 , 0.211, 0.947, 0.553, 0.978, 0.308, 0.18 , 0.387, 0.937, 0.691, 0.855, 0.489, 0.189],
0025 [0.507, 0.021, 0.958, 0.774, 0.418, 0.179, 0.259, 0.611, 0.9 , 0.446, 0.332, 0.73 , 0.976, 0.748, 0.488, 0.318],
0026 [0.712, 0.341, 0.468, 0.396, 0.001, 0.592, 0.87 , 0.632, 0.622, 0.555, 0.995, 0.525, 0.424, 0.138, 0.219, 0.791],
0027
0028 * TODO : do the same in bst : hmm will need to make local copy of the code in order to instrument it
0029 * OOPS : no need : found pilot error the precooked sequence was disabled
0030
0031 ::
0032
0033 In [3]: np.where( np.abs( a-b) > 2e-5 )
0034 Out[3]:
0035 (array([542827, 563864, 821078, 894016, 924236, 924236, 924236]),
0036 array([1, 1, 0, 1, 0, 1, 2]))
0037
0038 Out[6]: (array([542827, 924236, 924236, 924236]), array([1, 0, 1, 2]))
0039 In [7]: np.where( np.abs( a-b) > 1e-4 )
0040 Out[7]: (array([542827, 924236, 924236, 924236]), array([1, 0, 1, 2]))
0041 In [8]: np.where( np.abs( a-b) > 1e-3 )
0042 Out[8]: (array([924236, 924236, 924236]), array([0, 1, 2]))
0043 In [9]: np.where( np.abs( a-b) > 1e-4 )
0044 Out[9]: (array([542827, 924236, 924236, 924236]), array([1, 0, 1, 2]))
0045
0046 One direction in a million is totally off:
0047
0048 In [10]: a[924236]
0049 Out[10]: array([ 0.172, -0.125, 0.977, 0. ], dtype=float32)
0050
0051 In [11]: b[924236]
0052 Out[11]: array([-0.44 , -0.746, 0.501, 0. ], dtype=float32)
0053
0054 In [12]: a[542827]
0055 Out[12]: array([-0. , -0.001, 1. , 0. ], dtype=float32)
0056
0057 In [13]: b[542827]
0058 Out[13]: array([-0. , -0.001, 1. , 0. ], dtype=float32)
0059
0060
0061 """
0062 import os, numpy as np
0063
0064 def eprint( expr, lprefix="", rprefix="", tail="" ):
0065 ret = eval(expr)
0066 lhs = "%s%s" % (lprefix, expr)
0067 rhs = "%s%s" % (rprefix, ret )
0068 print("%-50s : %s%s" % ( lhs, rhs, tail ) )
0069 return ret
0070
0071 def epr(arg, **kwa):
0072 p = arg.find("=")
0073 if p > -1:
0074 var_eq = arg[:p+1]
0075 expr = arg[p+1:]
0076 label = var_eq
0077 else:
0078 label, expr = "", arg
0079 pass
0080 return eprint(expr, lprefix=label, **kwa)
0081
0082
0083 a_key = "A_FOLD"
0084 b_key = "B_FOLD"
0085
0086 A_FOLD = os.environ[a_key]
0087 B_FOLD = os.environ[b_key]
0088 NPY_NAME = os.environ["NPY_NAME"]
0089
0090
0091 if __name__ == '__main__':
0092 print("a_key : %20s A_FOLD : %s" % ( a_key, A_FOLD) )
0093 print("b_key : %20s B_FOLD : %s" % ( b_key, B_FOLD) )
0094 a_path = os.path.join(A_FOLD, NPY_NAME)
0095 b_path = os.path.join(B_FOLD, NPY_NAME)
0096
0097 a = np.load(a_path)
0098 b = np.load(b_path)
0099 print("a.shape %10s : %s " % (str(a.shape), a_path) )
0100 print("b.shape %10s : %s " % (str(b.shape), b_path) )
0101
0102