modulus-sym
modulus-sym copied to clipboard
🚀[FEA]: Highly inefficient sampling in Vector_Test
When working on a 3D problem, the memory usage of Vector_Test is too high compared to the actual sampled points. An example is shown below which caused crash.
test_fn = Test_Function(
name_ord_dict={
Trig_test: [k for k in range(8)],
},
diff_list=["grad"],
box=self.box,
)
self.v = Vector_Test(test_fn, test_fn, test_fn, mix=10)
This is because sample_vector_test in test_functions.py used itertools to perform the sampling, which takes too much memory when range(self.v1.num_fcn) is high. E.g.,
import random
import itertools
output_ind = random.sample(
set(
itertools.product(
range(1080),
range(1080),
range(1080),
)
),
10,
)
print(output_ind)
Maybe choosing random indices from the whole product indices pool (rangr(abc)) is a better choice.