[yt-svn] commit/yt: jzuhone: Merged in xarthisius/yt (pull request #1680)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Aug 11 08:22:02 PDT 2015


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/1f2ea0bf4184/
Changeset:   1f2ea0bf4184
Branch:      yt
User:        jzuhone
Date:        2015-08-11 15:21:50+00:00
Summary:     Merged in xarthisius/yt (pull request #1680)

Use stronger FNV algorithm instead of XOR for calculating selection hash
Affected #:  1 file

diff -r 87b696c1a0e3c58fd6719b1dfc973b82f1624c77 -r 1f2ea0bf41846f243b50558c5eb9828bf06a3da2 yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -446,7 +446,7 @@
     @cython.wraparound(False)
     @cython.cdivision(True)
     cdef int fill_mask_selector(self, np.float64_t left_edge[3],
-                                np.float64_t right_edge[3], 
+                                np.float64_t right_edge[3],
                                 np.float64_t dds[3], int dim[3],
                                 np.ndarray[np.uint8_t, ndim=3, cast=True] child_mask,
                                 np.ndarray[np.uint8_t, ndim=3] mask,
@@ -603,9 +603,12 @@
         return mask.view("bool")
 
     def __hash__(self):
+        # https://bitbucket.org/yt_analysis/yt/issues/1052/field-access-tests-fail-under-python3
+        # http://www.eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx
         cdef np.int64_t hash_val = 0
         for v in self._hash_vals() + self._base_hash():
-            hash_val ^= hash(v)
+            # FNV hash cf. http://www.isthe.com/chongo/tech/comp/fnv/index.html
+            hash_val = (hash_val * 16777619) ^ hash(v)
         return hash_val
 
     def _hash_vals(self):
@@ -1107,7 +1110,7 @@
 
     def _hash_vals(self):
         return (("norm_vec[0]", self.norm_vec[0]),
-                ("norm_vec[1]", self.norm_vec[1]), 
+                ("norm_vec[1]", self.norm_vec[1]),
                 ("norm_vec[2]", self.norm_vec[2]),
                 ("d", self.d))

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list