<commit_before>"""
Tests for jpmesh.coordinate.
"""

import unittest

from nose.tools import eq_

from jpmesh import FirstMesh, SecondMesh, ThirdMesh
from jpmesh import HalfMesh, QuarterMesh, OneEighthMesh
from jpmesh import Coordinate
from jpmesh import Angle


def _test_from_code(test_class, org_code, code, south_west):
    """
    Tests for SomeMesh.from_code.
    """
    mesh = test_class.from_code(org_code)
    eq_(mesh.code, code)
    eq_(mesh.south_west, south_west)


def _test_from_coordinate(test_class, code, south_west):
    """
    Tests for SomeMesh.from_coordinate.
    """
    mesh = test_class.from_coordinate(south_west)
    eq_(mesh.code, code)
    eq_(mesh.south_west, south_west)


class TestFirstMesh(unittest.TestCase):
    """
    Tests for jpmesh.coordinate.FirstMesh.
    """
    ORG_CODE = '5339'
    CODE = ORG_CODE
    SOUTH_WEST = Coordinate(
        lon=Angle.from_millisecond(500400000.0),
        lat=Angle.from_millisecond(127200000.0))

    def test_from_code(self):
        """
        Test for jpmesh.coordinate.FirstMesh.from_code.
        """
        _test_from_code(FirstMesh, self.ORG_CODE, self.CODE, self.SOUTH_WEST)

    def test_from_coordinate(self):
        """
        Test for jpmesh.coordinate.FirstMesh.from_coordinate.
        """
        _test_from_coordinate(FirstMesh, self.CODE, self.SOUTH_WEST)


class TestSecondMesh(unittest.TestCase):
    """
    Tests for jpmesh.coordinate.SecondMesh.
    """
    ORG_CODE = '5339-45'
    CODE = '533945'
    SOUTH_WEST = Coordinate(
        lon=Angle.from_millisecond(502650000.0),
        lat=Angle.from_millisecond(128400000.0))

    def test_from_code(self):
        """
        Test for jpmesh.coordinate.SecondMesh.from_code.
        """
        _test_from_code(SecondMesh, self.ORG_CODE, self.CODE, self.SOUTH_WEST)

    def test_from_coordinate(self):
        """
        Test for jpmesh.coordinate.SecondMesh.from_coordinate.
        """
        _test_from_coordinate(SecondMesh, self.CODE, self.SOUTH_WEST)


class TestThirdMesh(unittest.TestCase):
    """
    Tests for jpmesh.coordinate.ThirdMesh.
    """
    ORG_CODE = '5339-35-96'
    CODE = '53393596'
    SOUTH_WEST = Coordinate(
        lon=Angle.from_millisecond(502920000.0),
        lat=Angle.from_millisecond(128370000.0))

    def test_from_code(self):
        """
        Test for jpmesh.coordinate.ThirdMesh.from_code.
        """
        _test_from_code(ThirdMesh, self.ORG_CODE, self.CODE, self.SOUTH_WEST)

    def test_from_coordinate(self):
        """
        Test for jpmesh.coordinate.ThirdMesh.from_coordinate.
        """
        _test_from_coordinate(ThirdMesh, self.CODE, self.SOUTH_WEST)


class TestHalfMesh(unittest.TestCase):
    """
    Tests for jpmesh.coordinate.HalfMesh.
    """
    ORG_CODE = '5339-35-96-4'
    CODE = '533935964'
    SOUTH_WEST = Coordinate(
        lon=Angle.from_millisecond(502942500.0),
        lat=Angle.from_millisecond(128385000.0))

    def test_from_code(self):
        """
        Test for jpmesh.coordinate.HalfMesh.from_code.
        """
        _test_from_code(HalfMesh, self.ORG_CODE, self.CODE, self.SOUTH_WEST)

    def test_from_coordinate(self):
        """
        Test for jpmesh.coordinate.HalfMesh.from_coordinate.
        """
        _test_from_coordinate(HalfMesh, self.CODE, self.SOUTH_WEST)


class TestQuarterMesh(unittest.TestCase):
    """
    Tests for jpmesh.coordinate.QuarterMesh.
    """
    ORG_CODE = '5339-35-96-1-4'
    CODE = '5339359614'<commit_msg>Improve the test coverage.<commit_after>"""
Tests for jpmesh.coordinate.
"""

import unittest

from nose.tools import eq_
from nose.tools import raises

from jpmesh import FirstMesh, SecondMesh, ThirdMesh
from jpmesh import HalfMesh, QuarterMesh, OneEighthMesh
from jpmesh import Coordinate
from jpmesh import Angle


def _test_from_code(test_class, org_code, code, south_west):
    """
    Tests for SomeMesh.from_code.
    """
    mesh = test_class.from_code(org_code)
    eq_(mesh.code, code)
    eq_(mesh.south_west, south_west)


def _test_from_coordinate(test_class, code, south_west):
    """
    Tests for SomeMesh.from_coordinate.
    """
    mesh = test_class.from_coordinate(south_west)
    eq_(mesh.code, code)
    eq_(mesh.south_west, south_west)


class TestFirstMesh(unittest.TestCase):
    """
    Tests for jpmesh.coordinate.FirstMesh.
    """
    ORG_CODE = '5339'
    CODE = ORG_CODE
    SOUTH_WEST = Coordinate(
        lon=Angle.from_millisecond(500400000.0),
        lat=Angle.from_millisecond(127200000.0))

    def test_from_code(self):
        """
        Test for jpmesh.coordinate.FirstMesh.from_code.
        """
        _test_from_code(FirstMesh, self.ORG_CODE, self.CODE, self.SOUTH_WEST)

    def test_from_coordinate(self):
        """
        Test for jpmesh.coordinate.FirstMesh.from_coordinate.
        """
        _test_from_coordinate(FirstMesh, self.CODE, self.SOUTH_WEST)

    @raises(ValueError)
    def test_invalid_lat_number(self):
        FirstMesh(100, 0)

    @raises(ValueError)
    def test_invalid_lon_number(self):
        FirstMesh(0, 100)

    @raises(ValueError)
    def test_invalid_code_lat(self):
        FirstMesh.from_code('53393')


class TestSecondMesh(unittest.TestCase):
    """
    Tests for jpmesh.coordinate.SecondMesh.
    """
    ORG_CODE = '5339-45'
    CODE = '533945'
    SOUTH_WEST = Coordinate(
        lon=Angle.from_millisecond(502650000.0),
        lat=Angle.from_millisecond(128400000.0))

    def test_from_code(self):
        """
        Test for jpmesh.coordinate.SecondMesh.from_code.
        """
        _test_from_code(SecondMesh, self.ORG_CODE, self.CODE, self.SOUTH_WEST)

    def test_from_coordinate(self):
        """
        Test for jpmesh.coordinate.SecondMesh.from_coordinate.
        """
        _test_from_coordinate(SecondMesh, self.CODE, self.SOUTH_WEST)

    @raises(ValueError)
    def test_invalid_lat_number(self):
        SecondMesh(self.SOUTH_WEST, 9, 0)

    @raises(ValueError)
    def test_invalid_lon_number(self):
        SecondMesh(self.SOUTH_WEST, 0, 9)

    @raises(ValueError)
    def test_invalid_code(self):
        SecondMesh.from_code('5339356')


class TestThirdMesh(unittest.TestCase):
    """
    Tests for jpmesh.coordinate.ThirdMesh.
    """
    ORG_CODE = '5339-35-96'
    CODE = '53393596'
    SOUTH_WEST = Coordinate(
        lon=Angle.from_millisecond(502920000.0),
        lat=Angle.from_millisecond(128370000.0))

    def test_from_code(self):
        """
        Test for jpmesh.coordinate.ThirdMesh.from_code.
        """
        _test_from_code(ThirdMesh, self.ORG_CODE, self.CODE, self.SOUTH_WEST)

    def test_from_coordinate(self):
        """
        Test for jpmesh.coordinate.ThirdMesh.from_coordinate.
        """
        _test_from_coordinate(ThirdMesh, self.CODE, self.SOUTH_WEST)

    @raises(ValueError)
    def test_invalid_lat_number(self):
        ThirdMesh(self.SOUTH_WEST, 10, 0)

    @raises(ValueError)
    def test_invalid_lon_number(self):
        ThirdMesh(self.SOUTH_WEST, 0, 10)

    @raises(ValueError)
    def test_invalid_code(self):
        ThirdMesh.from_code('533935379')


class TestHalfMesh(unittest.TestCase):
    """
    Tests for jpmesh.coordinate.HalfMesh.
    """
    ORG_CODE = '5339-35-96-4'
    CODE = '533935964'
    SOUTH_WEST = Coordinate(
        lon=Angle.from_millisecond(502942500.0),
        lat=Angle.from_millisecond(128385000.0))

    def test_from_code(self):
        """
        Test for jpmesh.coordinate.HalfMesh.from_code.
        """
        _test_from_code(HalfMesh, self.ORG_CODE, self.CODE, self.SOUTH_WEST)

    def test_from_coordinate(self):
        """
        Test for jpmesh.coordinate.HalfMesh.from_coordinate.
        """
        _test_from_coordinate(HalfMesh, self.CODE, self.SOUTH_WEST)

    @raises(ValueError)
    def test_invalid_div_index(self):
        HalfMesh(self.SOUTH_WEST, 5)

    @raises(ValueError)
    def test_invalid_code(self):
        HalfMesh.from_code('53393537')


class TestQuarterMesh(unittest.TestCase):
    """
    Tests for jpmesh.coordinate.QuarterMesh.
    """
    ORG_CODE = '5339-35-96-1-4'
    CODE = '5339359614'
{'fraction_non_alphanumeric': 0.10925607660201325, 'fraction_numerical': 0.0427203535477535, 'mean_word_length': 3.0152784622966977, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3052359', 'n_tokens_mistral': 3150, 'n_tokens_neox': 2812, 'n_words': 433}