mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-15 12:03:42 +02:00
feat: hashing algorithm changed to md5
This commit is contained in:
parent
b2d5263ea3
commit
ded21e792f
1 changed files with 8 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
||||||
import warnings
|
import warnings
|
||||||
|
import hashlib
|
||||||
import pickle
|
import pickle
|
||||||
from math import gcd
|
from math import gcd
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
@ -685,10 +686,13 @@ class Obs:
|
||||||
return '{:.0f}({:2.0f})'.format(self.value, self._dvalue)
|
return '{:.0f}({:2.0f})'.format(self.value, self._dvalue)
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return hash((np.array([self.value]).astype(np.float32)[0],
|
hash_tuple = (np.array([self.value]).astype(np.float32).data.tobytes(),)
|
||||||
tuple([o.astype(np.float32).data.tobytes() for o in self.deltas.values()]),
|
hash_tuple += tuple([o.astype(np.float32).data.tobytes() for o in self.deltas.values()])
|
||||||
tuple(np.array([o.errsq() for o in self.covobs.values()]).astype(np.float32).data.tobytes()),
|
hash_tuple += tuple([np.array([o.errsq()]).astype(np.float32).data.tobytes() for o in self.covobs.values()])
|
||||||
tuple(self.names)))
|
hash_tuple += tuple([o.encode() for o in self.names])
|
||||||
|
m = hashlib.md5()
|
||||||
|
[m.update(o) for o in hash_tuple]
|
||||||
|
return int(m.hexdigest(), 16)
|
||||||
|
|
||||||
# Overload comparisons
|
# Overload comparisons
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue