Linked Questions
20 questions linked to/from Most efficient property to hash for numpy array
0
votes
1
answer
267
views
Unique arrays in list python [duplicate]
How can I get the unique arrays from such a list below?
data =[np.array([ 10, 17]),
np.array([ 10, 17]),
np.array([ 1, 17, 34]),
np.array([ 1, 17, 34]),
np.array([ 20, 50, ...
3
votes
0
answers
89
views
Dictionaries with numpy - Can I use XY coordinates as a hash? [duplicate]
I have a numpy matrix representing a map of XY coordinates:
n = [[0,0],[2,5],[3,1]]
Each coordinate is connected to a number of other coordinates, for example:
[0,0]:[5,2],[3,7]
[2,5]:[1,4]
[3,1]:[3,...
330
votes
20
answers
289k
views
Best implementation for hashCode method for a collection
How do we decide on the best implementation of hashCode() method for a collection (assuming that equals method has been overridden correctly) ?
226
votes
4
answers
97k
views
hash function in Python 3.3 returns different results between sessions
I've implemented a BloomFilter in python 3.3, and got different results every session. Drilling down this weird behavior got me to the internal hash() function - it returns different hash values for ...
60
votes
5
answers
43k
views
Get the same hash value for a Pandas DataFrame each time
My goal is to get unique hash value for a DataFrame. I obtain it out of .csv file.
Whole point is to get the same hash each time I call hash() on it.
My idea was that I create the function
def ...
28
votes
3
answers
17k
views
Fast way to Hash Numpy objects for Caching
Implementing a system where, when it comes to the heavy mathematical lifting, I want to do as little as possible.
I'm aware that there are issues with memoisation with numpy objects, and as such ...
18
votes
4
answers
14k
views
How to generate a Hash or checksum value on Python Dataframe (created from a fixed width file)?
I have 2 fixed width files like below (only change is Date value starting at position 14).
sample_hash1.txt
GOKULKRISHNA 04/17/2018
ABCDEFGHIJKL 04/17/2018
111111111111 04/17/2018
sample_hash2.txt
...
14
votes
2
answers
16k
views
How to make a tuple including a numpy array hashable?
One way to make a numpy array hashable is setting it to read-only. This has worked for me in the past. But when I use such a numpy array in a tuple, the whole tuple is no longer hashable, which I do ...
8
votes
3
answers
8k
views
Removing duplicates from a list of numPy arrays
I have an ordinary Python list that contains (multidimensional) numPy arrays, all of the same shape and with the same number of values. Some of the arrays in the list are duplicates of earlier ones.
...
7
votes
2
answers
918
views
python: bookkeeping dependencies in cached attributes that might change
I have a class A with three attributes a,b,c, where a is calculated from b and c (but this is expensive). Moreover, attributes b and c are likely to change over times. I want to make sure that:
a is ...
2
votes
4
answers
3k
views
Hash Value for 3D Vector
Is there a way to represent a 3D Vector as a definite number? I mean that two vectors with different values can't ever have the same hash value. I'm sure there already is a question about this but I ...
2
votes
1
answer
3k
views
Detecting a change to a numpy array
What I'm trying to do is provide a GUI for displaying some numpy arrays, and wire up IPython so you can manipulate the data however you like. I have all the IPython stuff working, the problem is how ...
1
vote
1
answer
1k
views
Why is md5 hashing so much faster on strings than on numpy arrays in python?
In python/numpy, I have a 10,000x10,000 array named random_matrix. I use md5 to compute the hash for str(random_matrix) and for random_matrix itself. It takes 0.00754404067993 seconds on the string ...
3
votes
1
answer
5k
views
Get a hashable numpy memory view
I want to hash numpy arrays without copying the data into a bytearray first.
Specifically, I have a contiguous read-only two-dimensional int64 numpy array A with unique rows. To be concrete, let's ...
8
votes
1
answer
924
views
How does np.ndarray.tobytes() work for dtype "object"?
I encountered a strange behavior of np.ndarray.tobytes() that makes me doubt that it is working deterministically, at least for arrays of dtype=object.
import numpy as np
print(np.array([1,[2]])....