def test_unicode_1_128(self):
     """Accepts Unicode input"""
     test_case = u"abc"
     self.assertTrue(isinstance(metrohash128(test_case), long))
 def test_unicode_2_128(self):
     """Accepts Unicode input outside of ASCII range"""
     test_case = u'\u2661'
     self.assertTrue(isinstance(metrohash128(test_case), long))
 def test_string_unicode_128(self):
     """Empty Python string has same hash value as empty Unicode string
     """
     self.assertEqual(metrohash128(""), metrohash128(u""))
 def test_consistent_encoding_128(self):
     """ASCII-range Unicode strings have the same hash values as ASCII strings
     """
     text = u"abracadabra"
     self.assertEqual(metrohash128(text), metrohash128(text.encode("utf-8")))
示例#5
0
def _metro_hash_128(val: bytes, seed: int = 1337):
    h: bytes = metrohash.metrohash128(val, seed)

    h1, h2 = np.frombuffer(h, dtype=np.uint64, offset=0)
    return h1, h2
 def test_unicode_2_128(self):
     """Accepts Unicode input outside of ASCII range"""
     test_case = u'\u2661'
     self.assertTrue(isinstance(metrohash128(test_case), long))
 def test_unicode_1_128(self):
     """Accepts Unicode input"""
     test_case = u"abc"
     self.assertTrue(isinstance(metrohash128(test_case), long))
 def test_consistent_encoding_128(self):
     """ASCII-range Unicode strings have the same hash values as ASCII strings
     """
     text = u"abracadabra"
     self.assertEqual(metrohash128(text),
                      metrohash128(text.encode("utf-8")))
 def test_string_unicode_128(self):
     """Empty Python string has same hash value as empty Unicode string
     """
     self.assertEqual(metrohash128(""), metrohash128(u""))