0

I have a numpy array with shape (1,x,1) and the second one also with shape (1,x,1). I wonder how can I check whether they are the same? Examples:

1. First:

[[[ 2]
  [ 3]
  [ 4]
  [ 5]
  [ 6]
  [ 7]
  [ 8]
  [ 9]
  [ 4]
  [ 6]
  [10]]]

Second:

[[[ 2]
  [ 3]
  [ 4]
  [ 5]
  [ 6]
  [ 7]
  [ 8]
  [ 9]
  [ 4]
  [ 6]
  [10]]]

Response: True

2.

First:

[[[ 2]
  [ 3]
  [ 4]
  [ 5]
  [ 6]
  [ 7]
  [ 8]
  [ 9]
  [ 4]]]

Second:

[[[ 1]
  [ 2]
  [ 3]
  [ 5]
  [ 6]
  [ 2]
  [ 8]
  [ 3]
  [ 5]]]

Response: False

2

1 Answer 1

0

There is already a SO question with that topic and a good answer by @Juh_ link.

The solution:

(A==B).all()
Sign up to request clarification or add additional context in comments.

2 Comments

np.array_equal will work, too?
Yes it should, it's also mentioned in the answer :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.