numpy.nan weird behaviour in hashed object
By : Matthew Martel
Date : March 29 2020, 07:55 AM
will help you I am experiencing a weird behaviour when using numpy.nan that I can't understand. Here is a minimal example: , If you use code :
_bool3key.__logic_sort__ = {0:1, nan:0 , 1:1}
In [17]: _bool3key(float('nan'))
KeyError: nan
def _bool3key(x, logic_sort={0: 1, 1: 1}):
"""
Defines the keys used to order the list.
The only allowed values are True, False, 1,0 and nan.
"""
return 0 if np.isnan(x) else logic_sort[x]

Weird behaviour with numpy array operations
By : HCarlos
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , When you slice a numpy array as you are doing in the example, you get a view of the data rather than a copy. See:

numpy diff weird behaviour
By : Aravind
Date : March 29 2020, 07:55 AM
Hope that helps .tolist() is a better way of converting an array to a list (or nested lists). It carries the conversion all the way down. list() just iterates on one level. And since an array is already iterable, I don't think list(anarray) does anything useful. start with an array: code :
In [789]: z
Out[789]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=uint8)
In [790]: type(list(z)[0])
Out[790]: numpy.uint8
In [791]: type([i for i in z][0])
Out[791]: numpy.uint8
In [792]: type(z.tolist()[0])
Out[792]: int
In [793]: np.diff(z.tolist())
Out[793]: array([1, 1, 1, 1, 1, 1, 1, 1, 1])
In [794]: np.diff(list(z))
Out[794]: array([1, 1, 1, 1, 1, 1, 1, 1, 1], dtype=uint8)
In [795]: np.diff(z.astype('int'))
Out[795]: array([1, 1, 1, 1, 1, 1, 1, 1, 1])
In [796]: np.diff(z)
Out[796]: array([1, 1, 1, 1, 1, 1, 1, 1, 1], dtype=uint8)
In [797]: np.array(list(z))
Out[797]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=uint8)

Weird Python / numpy UnboundLocalError behaviour
By : Joel E. Datoon
Date : March 29 2020, 07:55 AM
will help you I am working on Python 2.7.12 and numpy 1.12.0 and observing the following behavior. Is this expected? I assumed that "a" to be in the scope w.r.t "f2" in both the cases how is accessing the "a" different than accessing a[ind, :]? , In your first example, you used augmented assignment:

Numpy dotproduct weird behaviour
By : Freezyflame
Date : March 29 2020, 07:55 AM
Does that help From help(np.dot), we learn that, np.dot(x,y) is a sum product over the last axis of x and the secondtolast of y In the case of np.dot(a, b), the last axis of a is 4 and the length of the only axis of b is 1. They don't match: fail. code :
>>> np.dot(a, np.resize(b,a.shape[1]))
array([1230])

