Created
April 29, 2020 01:44
-
-
Save CharlesAverill/4c51dfd3bb3d858d6361dab44ba93626 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
matrix_shape = matrix.shape | |
flat_matrix = matrix.flatten() | |
ls_matrix = flat_matrix.tolist() | |
num_items = len(ls_matrix) | |
for stricken in range(int(num_items * self.v_ratio)): | |
if self.value: | |
ls_matrix[random.randint(0, len(ls_matrix) - 1)] = self.value | |
else: | |
ls_matrix[random.randint(0, len(ls_matrix) - 1)] = random.uniform(self.low_bound, self.high_bound) | |
matrix = np.array(ls_matrix) | |
matrix = np.reshape(matrix, matrix_shape) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment