runlmc.util.testing_utils module¶
The following methods are useful for generating various matrices for testing.
“PSDT” stands for positive semi-definite Toeplitz (and, implicitly, symmetric).
-
class
runlmc.util.testing_utils.BasicModel(dists, Y, kern)[source]¶
-
class
runlmc.util.testing_utils.RandomTest(methodName='runTest')[source]¶ Bases:
unittest.case.TestCaseThis test case sets the random seed to be based on the time that the test is run.
If there is a SEED variable in the enviornment, then this is used as the seed.
Sets both random and numpy.random. Prints the seed to stdout before running each test case.
-
class
runlmc.util.testing_utils.SingleGradOptimizer(lipschitz=1)[source]¶ Bases:
paramz.optimization.optimization.Optimizer
-
runlmc.util.testing_utils.check_np_lists(a, b, atol=1e-07, rtol=1e-07)[source]¶ Verifies that two lists of numpy arrays are all close. :param a: :param b:
-
runlmc.util.testing_utils.exp_decr_toep(n)[source]¶ Returns: top row of a PSDT matrix of size n with terms exponentially decreasing in distance from the main diagonal; the rate of which is randomly generated but at least \(e\).
-
runlmc.util.testing_utils.poor_cond_toep(n)[source]¶ Parameters: n – size of output Returns: the top row of a randomly scaled PSDT matrix whose \(L^2\) condition number scales exponentially with n
-
runlmc.util.testing_utils.rand_pd(n)[source]¶ Returns: a random n by n symmetric PSD matrix with positive entries
-
runlmc.util.testing_utils.random_toep(n)[source]¶ Returns: top row of a random PSDT matrix of size n.
-
runlmc.util.testing_utils.run_main(f, help_str)[source]¶ A helper function which is re-used in setting up benchmarks for kernels that are shaped in a specific manner; namely, sums of Kronecker products of small dense and large Toeplitz matrices.
This function reads in command-line arguments and executes a simple benchmarking script.
Parameters: - f – benchmarking function to pass generated inputs with user-specified parameters to.
- help_str – a help-string to be printed when the user does not call a correct invocation of the program.