2

I have a question about identity testing using numpy. Please, attend at this piece of code:

#! /usr/bin/env python
# encoding: UTF-8



import numpy

data = numpy.array([[1, 2, 3],
                [4, 5, 6],
                [7, 8, 9]])

This returns False, of course

row1 = numpy.array([5, 1, 2])

print row1 in data

This should give false as well, but because it starts with one element of the rows of data (4), it returns True.

row2 = numpy.array([4, 8, 9])
print row2 in data

Somebody can explain the reason in depth?

Thank you all for your time!

Dargor
  • 623
  • 1
  • 4
  • 12

0 Answers0