Uh oh!
There was an error while loading. Please reload this page.
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.
jasper256
commented
Sep 2, 2019
I have now added all methods I intended to, but can add more if people have suggestions. I also formatted with python/black as recommended. One mild bug that persists is the issue of printing out Matrix objects. For some reason, after a couple (I believe it's two, but it might vary) are printed, the next one to be printed is formatted incorrectly. This causes the doctest to fail in one case. I don't believe this is an error with the str method because when playing around in IDLE I found that I can get any Matrix to print correctly, but when I print a few in a row the bug occurs. Please let me know if anyone knows how to fix this, as well as any general feedback. |
…ests in matrix_class.py. Also implemented eq and ne comparison operations
|
…d and fixed bug in cofactors method
|
McDic
commented
Sep 4, 2019
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()importrandomsize=int(input("Input size: "))
mat= [[random.random() *100forjinrange(1, size+1)] foriinrange(size)]
mat=Matrix(mat)
print(mat.determinant())I think you need more optimizations. |
McDic
commented
Sep 4, 2019
And I meant clean string style for Your initial commit shows strings like and I intended But I don't think fixing |
jasper256
commented
Sep 7, 2019
@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. |
cclauss
commented
Sep 8, 2019
This is in a useful state and passes the tests so let’s land and the improvements requested above can come as pull requests. |
* 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!