Skip to content

Numpy append 2D array in for loop over rows

I want to append a 2D array created within a for-loop vertically. I tried append method, but this won’t stack vertically (I wan’t to avoid reshaping the result later), and I tried the vstack() function, but this won’t work on an empty array. Does anyone know how to solve this? I can think of…

Question regarding a matrix class function

First, here is my code: When adding two (non-zero) matrices I can not make the result be printed nicely as my __str__ method would do, instead of having I get the usual, Does anyone have an idea on how to fix the issue? Answer The return type of add function is a list. It should be a matrix.