Specific code below
The class LinearSystem:
Def __init__ (self, A, b) :
Assert A.r ow_num ()==len (b), "row num of the A must same with the len of the" b "
Self. _m=A.r ow_num ()
The self) _n=A.c ol_num ()
Assert the self) _m==self) _n # TODO: this is not restriction
Self. Ab=[Vector (A.r ow_vector (I) + (b) (I)))
For I in range (self) _m)]
Pycharm suggests TypeError: 'Vector' object is not callable
Problem is that the code and the teacher is the same error, using the teacher report the same error code and test code, master production,
CodePudding user response:
Pycharm suggests TypeError: 'Vector' object is not callable-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
'XXX' object is not callable error illustrates the XXX object cannot call!
From the point of your code, you are using a Vector (), that means is to call the constructor or the object name for normal function of the Vector,
If is traversing object, usually with brackets to indexes, such as Vector () changed to: Vector []
The Vector (A.r ow_vector (I) + (b) (I)))
The outer parentheses into brackets:
The Vector [A.r ow_vector (I) + (I) [b]]
Try it!
-- -- -- -- -- -- -- -- -- -- --
In addition, before you first in the above code print your A.r respectively ow_vector (I) and b (I)
Print (A.r ow_vector (I))
Print (b) (I))
Will look at similar object cannot call XXX mistakes?
CodePudding user response:
Thank you upstairs, the problem has been solved, it is self. Ab=[Vector (A.r ow_vector (I) + (b) (I))) in (I) is not parentheses, square brackets, after all, is a novice, have spent a lot of time, the result is himself a small negligence, thank you again for great god above,CodePudding user response: