Added OOP approach to matrices - #1165
Conversation
…responding doctests
…onding doctests) to matrix_class.py A small bug persists that causes the doctest to fail. After a couple Matrix objects are printed, the next one is printed in a different format.
…ests in matrix_class.py. Also implemented eq and ne comparison operations
|
…d and fixed bug in cofactors method
|
|
Try this at the end of the code. Your program will never terminate if given input is larger than 4. if __name__ == "__main__":
pass
# import doctest
# test = doctest.testmod()
import random
size = int(input("Input size: "))
mat = [[random.random() * 100 for j in range(1, size+1)] for i in range(size)]
mat = Matrix(mat)
print(mat.determinant())I think you need more optimizations. |
|
And I meant clean string style for Your initial commit shows strings like and I intended But I don't think fixing |
|
@McDic I just wanted to say that I've seen your comments and appreciate the feedback. Sorry if it is taking me a while to make changes but school just started for me and I have been very busy. So this might take me a while to complete, but don't think I have forgotten about it. |
* Added OOP aproach to matrices * created methods for minors, cofactors, and determinants and added corresponding doctests * Added methods for adjugate, inverse, and identity (along with corresponding doctests) to matrix_class.py A small bug persists that causes the doctest to fail. After a couple Matrix objects are printed, the next one is printed in a different format. * formatted matrix_class.py with python/black * implemented negation and exponentiation as well as corresponding doctests in matrix_class.py. Also implemented eq and ne comparison operations * changed __str__ method in matrix_class.py to align with numpy standard and fixed bug in cofactors method * removed property decorators from several methods in matrix_class.py

This is far from done but just a little project I was working on for fun that I thought would be nice to add to this repo eventually. I still need to add determinants, cofactors, etc. but I thought it might be good to post this and see if I got any advice / criticisms of things to think or if you guys thought it looked good to keep going the way it is. I just noticed that you guys are now recommending running Python Black, which I haven't done yet but will get to soon. Anyway, let me know what you think!