I’m currently an engineering student learning python, and for an assignment I have to write a very simple code to define an array as M, then take an input row defined as r and have the program check to see if the row r is in array M, if so then print row r, and if not then print “Line does not exist in array M”. I think my code is good and it works great in jupyter notebook, however to submit my assignments we use a software called codegrade to check our code and grade it, I believe it uses pytest, and when I run my code through codegrade it gives me the following error.
________________________ ERROR collecting test_file.py _________________________
E OSError: pytest: reading from stdin while output is captured! Consider using `-s`.
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
1 error in 0.22s
This is my code: import numpy as np #define array M and row input r M = np.array([[1, 2, 3],[4, 5, 6],[7, 8, 9]]) r = int(input("an integer indicating which row should be stripped from the matrix")) #define function get_code to take user input r and remove it from array M and print the removed row, #unless it does not exist, then print Line does not exist in array M def get_code(M, r): if r < 0 or r >= M.shape[0]: print("Line does not exist in array M") else: removed_row = M[r] M = np.delete(M, r, axis=0) print(removed_row)
I can add an actual line of code to call the function for output or not, I get the same error.
From what I can tell it is because my code asks for user input, however I’m 99% sure I have done this other times and not had this error appear. I have tried my code as many different ways as I can and I cannot resolve this error. Thanks for your help!
submitted by /u/FishingEngineerGuy
[link] [comments]
r/learnpython I’m currently an engineering student learning python, and for an assignment I have to write a very simple code to define an array as M, then take an input row defined as r and have the program check to see if the row r is in array M, if so then print row r, and if not then print “Line does not exist in array M”. I think my code is good and it works great in jupyter notebook, however to submit my assignments we use a software called codegrade to check our code and grade it, I believe it uses pytest, and when I run my code through codegrade it gives me the following error. ________________________ ERROR collecting test_file.py _________________________ E OSError: pytest: reading from stdin while output is captured! Consider using `-s`. !!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!! 1 error in 0.22s This is my code: import numpy as np #define array M and row input r M = np.array([[1, 2, 3],[4, 5, 6],[7, 8, 9]]) r = int(input(“an integer indicating which row should be stripped from the matrix”)) #define function get_code to take user input r and remove it from array M and print the removed row, #unless it does not exist, then print Line does not exist in array M def get_code(M, r): if r < 0 or r >= M.shape[0]: print(“Line does not exist in array M”) else: removed_row = M[r] M = np.delete(M, r, axis=0) print(removed_row) I can add an actual line of code to call the function for output or not, I get the same error. From what I can tell it is because my code asks for user input, however I’m 99% sure I have done this other times and not had this error appear. I have tried my code as many different ways as I can and I cannot resolve this error. Thanks for your help! submitted by /u/FishingEngineerGuy [link] [comments]
I’m currently an engineering student learning python, and for an assignment I have to write a very simple code to define an array as M, then take an input row defined as r and have the program check to see if the row r is in array M, if so then print row r, and if not then print “Line does not exist in array M”. I think my code is good and it works great in jupyter notebook, however to submit my assignments we use a software called codegrade to check our code and grade it, I believe it uses pytest, and when I run my code through codegrade it gives me the following error.
________________________ ERROR collecting test_file.py _________________________
E OSError: pytest: reading from stdin while output is captured! Consider using `-s`.
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
1 error in 0.22s
This is my code: import numpy as np #define array M and row input r M = np.array([[1, 2, 3],[4, 5, 6],[7, 8, 9]]) r = int(input("an integer indicating which row should be stripped from the matrix")) #define function get_code to take user input r and remove it from array M and print the removed row, #unless it does not exist, then print Line does not exist in array M def get_code(M, r): if r < 0 or r >= M.shape[0]: print("Line does not exist in array M") else: removed_row = M[r] M = np.delete(M, r, axis=0) print(removed_row)
I can add an actual line of code to call the function for output or not, I get the same error.
From what I can tell it is because my code asks for user input, however I’m 99% sure I have done this other times and not had this error appear. I have tried my code as many different ways as I can and I cannot resolve this error. Thanks for your help!
submitted by /u/FishingEngineerGuy
[link] [comments]