python - ValueError: matrices are not aligned for copy error and x[:] -
i got valueerror given below.
valueerror: matrices not aligned copy error
it traced following line (i did not write code, trying use it):
x1[:] = _dotproduct(x1, u) the dot product numpy dot product, works fine, printing _dotproduct(x1, u) give valid answer. x1[:] not working.
what [:] mean? have never seen that.
also how can solve error of alignment?
edit:
have traced error x1[:], instead of can following:
hh=len(x1) x1[0:hh]=_dotproduct(x1, u)?
in case, since it's on left side of = sign, it's slice assignment. object x1 remains same object, contents replaced sequence on right. without [:], x1 assigned totally different object.
using slice assignment means if there other references same variable in program, of these see new contents. example, caller of function passes in container , function replaces contents. wouldn't possible without slice assignment.
Comments
Post a Comment