0

Does any one have any idea why the below is evaluating to True?

board[y_new:y_new + self.size, x_new:x_new + self.size]


array([[[ 75,   0, 130],
        [ 75,   0, 130],
        [ 75,   0, 130]],
       [[ 75,   0, 130],
        [ 75,   0, 130],
        [ 75,   0, 130]],
       [[ 75,   0, 130],
        [ 75,   0, 130],
        [ 75,   0, 130]]], dtype=uint8)

Above is my array.

When I check if a value is in the array col = np.array([255, 0, 64]) like this...

col in board[y_new:y_new + self.size, x_new:x_new + self.size]

I get

True

Its early in the morning and I still need my coffee but this makes NO sense to me right now.

5
  • 2
    Does this answer your question? "In" operator for numpy arrays?. The gist is, in does not work as you expect it to do for numpy arrays. Commented Jun 19, 2020 at 6:08
  • Not fully, but its a good start. Thanks Commented Jun 19, 2020 at 6:10
  • To me it looked like it was the exact same problem. What is not answered there? Commented Jun 19, 2020 at 6:12
  • I'll get back to you, I've now worked out the issue. My current solution is finding the 0 that is contained in both and evaluating to true. Your post is getting me on the right track. Maybe I'm missing something, I haven't tried all options on there yet. Will let you know Commented Jun 19, 2020 at 6:14
  • @JanChristophTerasa I stand corrected. It perfectly solved my issue in the end. Thanks Commented Jun 19, 2020 at 6:26

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.