<commit_before>import unittest
import numpy as np
import array
import math
from convertbng.util import (
    convert_bng,
    convert_lonlat,
    convert_to_osgb36,
    convert_osgb36_to_lonlat,
    convert_osgb36_to_etrs89,
    convert_etrs89_to_osgb36,
    convert_etrs89_to_lonlat,
    convert_epsg3857_to_wgs84
)
from convertbng.cutil import convert_bng as cconvert_bng
from ctypes import ArgumentError
from random import randrange


class ConvertbngTests(unittest.TestCase):
    """ Tests for convert_bng
    """

    def setUp(self):
        """ Set stuff up
        """
        pass

    def testConvertLonLat(self):
        """ Test multithreaded lon, lat --> BNG function """
        expected = (
            [516274.449, 398915.542],
            [173141.098, 521544.088]
        )
   
        result = convert_bng(
            [-0.32824866, -2.0183041005533306],
            [51.44533267, 54.589097162646141]
        )
        self.assertEqual(expected, result)

    def testCythonConvertLonLat(self):
        """ Test Cythonised multithreaded lon, lat --> BNG function """
        expected = (
            [516274.449, 398915.542],
            [173141.098, 521544.088]
        )
   
        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))

    def testCythonConvertList(self):
        """ Test Cythonised multithreaded lon, lat --> BNG function with lists """
        expected = (
            np.array([516274.449, 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])

    def testConvertBNG(self):
        """ Test multithreaded BNG --> lon, lat function """
        expected = (
            [-0.32822636, -2.01831249],
            [51.44533146, 54.58910536]
        )
        result = convert_lonlat(
            [516276L, 398915L],
            [173141L, 521545L]
        )
        self.assertEqual(expected, result)

    def testConvertLonLatSingle(self):
        """ Test lon, lat --> BNG conversion of single values """
        expected = ([651409.792], [313177.448])
        result = convert_bng(1.716073973, 52.658007833)
        self.assertEqual(expected, result)

    def testConvertTuple(self):
        """ Test lon, lat --> BNG conversion of tuples """
        expected = ([651409.792], [313177.448])
        result = convert_bng((1.716073973,), (52.658007833,))
        self.assertEqual(expected, result)

    def testConvertString(self):
        """ Test that an error is thrown for incorrect types """
        with self.assertRaises(ArgumentError) as result:
            convert_bng(['Foo'], ['Bar'])

    def testConvertIterable(self):
        """ Test lon, lat --> BNG conversion of tuples """
        expected = ([651409.792], [313177.448])
        result = convert_bng(iter([1.7160739736]), iter([52.658007833]))
        self.assertEqual(expected, result)<commit_msg>Fix test for Python 3 compatibility<commit_after>import unittest
import numpy as np
import array
import math
from convertbng.util import (
    convert_bng,
    convert_lonlat,
    convert_to_osgb36,
    convert_osgb36_to_lonlat,
    convert_osgb36_to_etrs89,
    convert_etrs89_to_osgb36,
    convert_etrs89_to_lonlat,
    convert_epsg3857_to_wgs84
)
from convertbng.cutil import convert_bng as cconvert_bng
from ctypes import ArgumentError
from random import randrange


class ConvertbngTests(unittest.TestCase):
    """ Tests for convert_bng
    """

    def setUp(self):
        """ Set stuff up
        """
        pass

    def testConvertLonLat(self):
        """ Test multithreaded lon, lat --> BNG function """
        expected = (
            [516274.449, 398915.542],
            [173141.098, 521544.088]
        )
   
        result = convert_bng(
            [-0.32824866, -2.0183041005533306],
            [51.44533267, 54.589097162646141]
        )
        self.assertEqual(expected, result)

    def testCythonConvertLonLat(self):
        """ Test Cythonised multithreaded lon, lat --> BNG function """
        expected = (
            [516274.449, 398915.542],
            [173141.098, 521544.088]
        )
   
        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))

    def testCythonConvertList(self):
        """ Test Cythonised multithreaded lon, lat --> BNG function with lists """
        expected = (
            np.array([516274.449, 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])

    def testConvertBNG(self):
        """ Test multithreaded BNG --> lon, lat function """
        expected = (
            [-0.32822636, -2.01831249],
            [51.44533146, 54.58910536]
        )
        result = convert_lonlat(
            [516276, 398915],
            [173141, 521545]
        )
        self.assertEqual(expected, result)

    def testConvertLonLatSingle(self):
        """ Test lon, lat --> BNG conversion of single values """
        expected = ([651409.792], [313177.448])
        result = convert_bng(1.716073973, 52.658007833)
        self.assertEqual(expected, result)

    def testConvertTuple(self):
        """ Test lon, lat --> BNG conversion of tuples """
        expected = ([651409.792], [313177.448])
        result = convert_bng((1.716073973,), (52.658007833,))
        self.assertEqual(expected, result)

    def testConvertString(self):
        """ Test that an error is thrown for incorrect types """
        with self.assertRaises(ArgumentError) as result:
            convert_bng(['Foo'], ['Bar'])

    def testConvertIterable(self):
        """ Test lon, lat --> BNG conversion of tuples """
        expected = ([651409.792], [313177.448])
        result = convert_bng(iter([1.7160739736]), iter([52.658007833]))
        self.assertEqual(expected, result)
{'fraction_non_alphanumeric': 0.11983980283425755, 'fraction_numerical': 0.14587184226740604, 'mean_word_length': 2.256268806419258, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1192058', 'n_tokens_mistral': 2665, 'n_tokens_neox': 2080, 'n_words': 430}