Check if two numpy arrays are identical

前端 未结 7 991
轻奢々
轻奢々 2020-12-10 15:47

Suppose I have a bunch of arrays, including x and y, and I want to check if they\'re equal. Generally, I can just use np.all(x == y) (

7条回答
  •  死守一世寂寞
    2020-12-10 16:38

    Well, not really an answer as I haven't checked if it break-circuits, but:

    assert_array_equal.

    From the documentation:

    Raises an AssertionError if two array_like objects are not equal.

    Try Except it if not on a performance sensitive code path.

    Or follow the underlying source code, maybe it's efficient.

提交回复
热议问题