[yt-svn] commit/yt: 3 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Nov 9 11:10:23 PST 2015
3 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/93d957bac570/
Changeset: 93d957bac570
Branch: yt
User: ngoldbaum
Date: 2015-11-03 20:59:29+00:00
Summary: Pass bytes to FNV hashing algorithm, don't rely on python hashes
Affected #: 1 file
diff -r f264885c3fb49044ba653bf1b29e2eb46e99db24 -r 93d957bac5701e6b0cb1418f83b3a7554bd9ae18 yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -42,6 +42,16 @@
cdef np.float64_t grid_eps = np.finfo(np.float64).eps
grid_eps = 0.0
+cdef np.int64_t fnv_hash(unsigned char[:] octets):
+ # https://bitbucket.org/yt_analysis/yt/issues/1052/field-access-tests-fail-under-python3
+ # FNV hash cf. http://www.isthe.com/chongo/tech/comp/fnv/index.html
+ cdef np.int64_t hash_val = 2166136261
+ cdef char octet
+ for octet in octets:
+ hash_val = hash_val ^ octet
+ hash_val = hash_val * 16777619
+ return hash_val
+
# These routines are separated into a couple different categories:
#
# * Routines for identifying intersections of an object with a bounding box
@@ -605,13 +615,15 @@
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 = 2166136261
+ # convert data to be hashed to a byte array, which FNV algorithm expects
+ hash_data = bytearray()
for v in self._hash_vals() + self._base_hash():
- # FNV hash cf. http://www.isthe.com/chongo/tech/comp/fnv/index.html
- hash_val = (hash_val * 16777619) ^ hash(v)
- return hash_val
+ if isinstance(v, tuple):
+ hash_data.extend(v[0].encode('ascii'))
+ hash_data.extend(str(v[1]).encode('ascii'))
+ else:
+ hash_data.extend(str(v).encode('ascii'))
+ return fnv_hash(hash_data)
def _hash_vals(self):
raise NotImplementedError
https://bitbucket.org/yt_analysis/yt/commits/974ebc47a7d6/
Changeset: 974ebc47a7d6
Branch: yt
User: ngoldbaum
Date: 2015-11-09 05:11:54+00:00
Summary: Use repr instead of str to generate better hash data.
http://stackoverflow.com/questions/3481289/converting-a-python-float-to-a-string-without-losing-precision
Affected #: 1 file
diff -r 93d957bac5701e6b0cb1418f83b3a7554bd9ae18 -r 974ebc47a7d65da5a8eaad3a374318f4749b2b14 yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -618,11 +618,12 @@
# convert data to be hashed to a byte array, which FNV algorithm expects
hash_data = bytearray()
for v in self._hash_vals() + self._base_hash():
+ print v
if isinstance(v, tuple):
hash_data.extend(v[0].encode('ascii'))
- hash_data.extend(str(v[1]).encode('ascii'))
+ hash_data.extend(repr(v[1]).encode('ascii'))
else:
- hash_data.extend(str(v).encode('ascii'))
+ hash_data.extend(repr(v).encode('ascii'))
return fnv_hash(hash_data)
def _hash_vals(self):
https://bitbucket.org/yt_analysis/yt/commits/1e45b8fbc35c/
Changeset: 1e45b8fbc35c
Branch: yt
User: ngoldbaum
Date: 2015-11-09 05:16:19+00:00
Summary: Remove print statement
Affected #: 1 file
diff -r 974ebc47a7d65da5a8eaad3a374318f4749b2b14 -r 1e45b8fbc35cf574ed81ed9b86f4fb9aae5ef4f2 yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -618,7 +618,6 @@
# convert data to be hashed to a byte array, which FNV algorithm expects
hash_data = bytearray()
for v in self._hash_vals() + self._base_hash():
- print v
if isinstance(v, tuple):
hash_data.extend(v[0].encode('ascii'))
hash_data.extend(repr(v[1]).encode('ascii'))
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