예제 #1
0
 def test_1_nsmall(self):
     "First 9 steps of the N-order curve in 2D"
     # test first 9 steps of the n-order curve in 2D
     tests = [((0, 0), 0), ((0, 1), 1), ((1, 0), 2), ((1, 1), 3),
              ((0, 2), 4), ((0, 3), 5), ((1, 2), 6), ((1, 3), 7),
              ((2, 0), 8)]
     for c, outcome in tests:
         self.assertEqual(nenc(c), outcome)
         self.assertEqual(c, ndec(outcome, 2))
예제 #2
0
 def test_nsmall(self):
     "First 9 steps of the N-order curve in 2D"
     # test first 9 steps of the n-order curve in 2D
     tests = [((0, 0), 0), ((0, 1), 1), ((1, 0), 2), ((1, 1), 3),
              ((0, 2), 4), ((0, 3), 5), ((1, 2), 6), ((1, 3), 7),
              ((2, 0), 8)]
     for c, outcome in tests:
         assert nenc(c) == outcome
         assert c == ndec(outcome, 2)
예제 #3
0
 def test_2_bug_dims(self):
     correct_sfc_keys = [
         1125899906842623,
         1125899906842624,
         1125899906842625,
         1125899906842626,
         1125899906842627,
         1125899906842628,
     ]
     coords = [(33554431, 33554431), (0, 33554432), (0, 33554433),
               (1, 33554432), (1, 33554433), (0, 33554434)]
     #for enc, dec, in [(nenc, ndec), (henc, hdec)]:
     for coord, correct_sfc_key in zip(coords, correct_sfc_keys):
         # assert nenc(coord) == correct_sfc_key
         self.assertEqual(nenc(coord), correct_sfc_key)
         # assert ndec(correct_sfc_key, 2) == coord
         self.assertEqual(ndec(correct_sfc_key, 2), coord)
예제 #4
0
def test_manual():
    # key = 72057594037927936-1
    key = 72057594037927936
    key = 72057594037927936 + 2
    n_dims = 4
    assert ndec(key, n_dims) != (0, 0, 0, 0)
예제 #5
0
 def test_4d(self):
     key = 72057594037927936
     n_dims = 4
     assert ndec(key, n_dims) != (0, 0, 0, 0)
예제 #6
0
 def test_3d(self):
     "One 3D coordinate forth and back (H- and N-order)"
     assert ndec(1903, 3) == (7, 9, 15)
     assert nenc((7, 9, 15)) == 1903
     assert henc((7, 9, 15)) == 2049
     assert hdec(2049, 3) == (7, 9, 15)