0
import numpy as np

pp = np.array(p)       # p is some array

print(pp[0])
print(pp[1])
print(pp[0] + pp[1])

results in : [138 138 138]
         [138 138 148]
         [20 20 40]

Why does this happen? Why is the addition wrong?

2
  • What exactly is p? Commented Mar 16, 2017 at 16:56
  • What is print(pp)? Commented Mar 16, 2017 at 16:57

1 Answer 1

1

Your array is evidently composed of unsigned bytes (dtype=uint8). Your values are wrapping around within the 0..255 range of this data type.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.