lundi 4 mars 2019

How to find a specific matrix by generating random matrix

I am trying to increase coverage of my test by making a test case which will be checking the if condition of s matrix in the following program. I dont know what matrix I pass to the function np.linalg.svd to get the specific s matrix for my test case.
To find that matrix I created the following program and I was expecting it to run until I get that matrix. However for some reason it stops after few execution generating an error Maximum recursion depth exceeded. I dont know why it is behaving like this.
I am running it by python program.py
Please help

import numpy as np
import random
import pivot as p


def randomGenerator():
    condition = True
    while(condition):
        matrices = np.random.rand(4, 4)
        print(matrices)
        u, s, v = np.linalg.svd(matrices, full_matrices=False)
        Rank = 0
        for i in range(len(s)):
            if s[i] < 0.01:
                s[i] = 0
                print(s)
                condition = False
            else:
                randomGenerator()
# Main #
randomGenerator()

Aucun commentaire:

Enregistrer un commentaire