The Python Oracle

Numpy: Why is numpy.array([2]).any() > 1 False?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Dreaming in Puzzles

--

Chapters
00:00 Numpy: Why Is Numpy.Array([2]).Any() ≫ 1 False?
00:18 Accepted Answer Score 6
00:39 Answer 2 Score 3
00:50 Thank you

--

Full question
https://stackoverflow.com/questions/1205...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #numpy

#avk47



ACCEPTED ANSWER

Score 6


It does return True. But (True > 1) == False. While the first part is 2 > 1 which of course is True.

As others posted, you probably want:

(numpy.array([2])  > 1).any()



ANSWER 2

Score 3


Perhaps you are confusing it with this

>>> (numpy.array([2]) > 1).any()
True