numpy all differing from builtin all

0 votes

What is the reason for this weirdness in numpy's all?

>>> import numpy as np
>>> np.all(xrange(10))
False
>>> np.all(i for i in xrange(10))
True

Jun 13 in Python by ana1504.k
• 7,350 points
17 views

1 answer to this question.

0 votes

Numpy.all does not understands generator expressions.

From the documentation

 numpy.all(a, axis=None, out=None)

    Test whether all array elements along a given axis evaluate to True.
    Parameters :    

    a : array_like

        Input array or object that can be converted to an array.
answered Jun 13 by SDeb
• 12,120 points

Related Questions In Python

0 votes
1 answer
0 votes
1 answer

Deleting elements from numpy array

Use the following code: import numpy as np a=np.array([1,2,3,4]) b=np.delete(a,2) OUTPUT: array([1, ...READ MORE

answered Jun 24 in Python by Fata
• 580 points

edited Jun 25 by Kalgi 20 views
+1 vote
2 answers

View onto a numpy array?

 just index it as you normally would. ...READ MORE

answered Oct 18, 2018 in Python by roberto
42 views
0 votes
1 answer
0 votes
1 answer

Printing a large numpy array

numpy.set_printoptions(threshold='nan') READ MORE

answered Jul 20, 2018 in Python by Nietzsche's daemon
• 4,260 points
82 views
0 votes
1 answer

Shift all indices in NumPy array

You can use the following : y = ...READ MORE

answered Feb 26 in Python by SDeb
• 12,120 points
150 views
0 votes
1 answer

Sum of distances from a point to all other points

You can use cdist - In [1]: from scipy.spatial.distance import ...READ MORE

answered Jun 10 in Python by SDeb
• 12,120 points
12 views