I have lots of matrices (as result of rotations, etc.), but I would be sure to store them only once. I thought about using a set :
print set([np.matrix([[0, 0],[0, 1],[1, 1],[2, 1]]),
np.matrix([[0, 0],[1, 0],[1, -1],[1, -2]])])
Unfortunately, I get :
TypeError: unhashable type: 'matrix'
It's sad because a set would be exactly the right data type to avoid repetitions, and be able to use union, intersection, etc.
How to work with sets of matrices in Python?
Aucun commentaire:
Enregistrer un commentaire