Пример #1
0
    def testLargeArrayConversionCython(self):
        """ Test that we don't get segmentation fault: 11 on large (1MM points) arrays using Cython """
        # London bounding box
        N = 51.691874116909894
        E = 0.3340155643740321
        S = 51.28676016315085
        W = -0.5103750689005356

        num_coords = 1000000
        lon_ls = np.random.uniform(W, E, [num_coords])
        lat_ls = np.random.uniform(S, N, [num_coords])
        cconvert_bng(lon_ls, lat_ls)
Пример #2
0
    def testLargeArrayConversionCython(self):
        """ Test that we don't get segmentation fault: 11 on large (1MM points) arrays using Cython """
        # London bounding box
        N = 51.691874116909894
        E = 0.3340155643740321
        S = 51.28676016315085
        W = -0.5103750689005356

        num_coords = 1000000
        lon_ls = np.random.uniform(W, E, [num_coords])
        lat_ls = np.random.uniform(S, N, [num_coords])
        cconvert_bng(lon_ls, lat_ls)
Пример #3
0
    def testCythonConvertLonLat(self):
        """ Test Cythonised multithreaded lon, lat --> BNG function """
        expected = ([516274.46000000002, 398915.554], [173141.101, 521544.09000000003])

        result = cconvert_bng(np.array([-0.32824866, -2.0183041005533306]), np.array([51.44533267, 54.589097162646141]))
        # dump array result into list
        a, b = list(result[0]), list(result[1])
        self.assertEqual(expected, (a, b))
Пример #4
0
    def testCythonConvertList(self):
        """ Test Cythonised multithreaded lon, lat --> BNG function with lists """
        expected = (np.array([516274.460,
                              398915.542]), np.array([173141.098, 521544.088]))

        result = cconvert_bng([-0.32824866, -2.0183041005533306],
                              [51.44533267, 54.589097162646141])
        self.assertEqual(expected[0][0], result[0][0])
Пример #5
0
    def testCythonConvertLonLat(self):
        """ Test Cythonised multithreaded lon, lat --> BNG function """
        expected = ([516274.46000000002,
                     398915.554], [173141.101, 521544.09000000003])

        result = cconvert_bng(np.array([-0.32824866, -2.0183041005533306]),
                              np.array([51.44533267, 54.589097162646141]))
        # dump array result into list
        a, b = list(result[0]), list(result[1])
        self.assertEqual(expected, (a, b))
Пример #6
0
    def testCythonConsistency(self):
        """ Ensure Ctypes and Cython give same results """
        # London bounding box
        N = 51.691874116909894
        E = 0.3340155643740321
        S = 51.28676016315085
        W = -0.5103750689005356
        num_coords = 100

        rand = randrange(0, 100)
        lon_ls = np.random.uniform(W, E, [num_coords])
        lat_ls = np.random.uniform(S, N, [num_coords])
        # result is a list, so convert to an array. Ugh.
        res_ctypes = np.array(convert_bng(lon_ls, lat_ls)[0][rand])
        res_cython = cconvert_bng(lon_ls, lat_ls)[0][rand]

        self.assertEqual(res_ctypes, res_cython)
Пример #7
0
    def testCythonConsistency(self):
        """ Ensure Ctypes and Cython give same results """
        # London bounding box
        N = 51.691874116909894
        E = 0.3340155643740321
        S = 51.28676016315085
        W = -0.5103750689005356
        num_coords = 100

        rand = randrange(0, 100)
        lon_ls = np.random.uniform(W, E, [num_coords])
        lat_ls = np.random.uniform(S, N, [num_coords])
        # result is a list, so convert to an array. Ugh.
        res_ctypes = np.array(convert_bng(lon_ls, lat_ls)[0][rand])
        res_cython = cconvert_bng(lon_ls, lat_ls)[0][rand]

        self.assertEqual(res_ctypes, res_cython)
Пример #8
0
    def testCythonConvertList(self):
        """ Test Cythonised multithreaded lon, lat --> BNG function with lists """
        expected = (np.array([516274.460, 398915.542]), np.array([173141.098, 521544.088]))

        result = cconvert_bng([-0.32824866, -2.0183041005533306], [51.44533267, 54.589097162646141])
        self.assertEqual(expected[0][0], result[0][0])