<commit_before>import unittest
from math import pi

from sections.core import BaseSection, Dimensions


class BaseSectionTests(unittest.TestCase):

    def test_initial_state(self):
        section = BaseSection()
        
        self.assertEqual(section.density, 1.0)
        self.assertEqual(section.position, (0.0, 0.0, 0.0))
        self.assertIsInstance(section.dimensions, Dimensions)
    
    
    def test_setting_density(self):
        section = BaseSection(density=2)
        
        self.assertRaises(AttributeError, setattr, section, "density", 3.0)
        self.assertEqual(section.density, 2.0)
        self.assertIsInstance(section.density, float)
        
        self.assertRaises(ValueError, section.set_density, "abc")
        self.assertRaises(ValueError, section.set_density, 0.0)

        section.set_density(3)
        self.assertEqual(section.density, 3.0)
        self.assertIsInstance(section.density, float)
        
    
    def test_setting_position(self):
        section = BaseSection()
        
        self.assertRaises(AttributeError, setattr, section, "position", (0, 0, 0))
        
        section.set_position(d1=1)
        self.assertIsInstance(section.position[0], float)
        self.assertEqual(section.position, (1.0, 0.0, 0.0))

        section.set_position(d2=2)
        self.assertIsInstance(section.position[1], float)
        self.assertEqual(section.position, (1.0, 2.0, 0.0))
        
        section.set_position(theta=3)
        self.assertIsInstance(section.position[2], float)
        self.assertEqual(section.position, (1.0, 2.0, 3.0))
        
        section.set_position(4, 5, 6)
        self.assertEqual(section.position, (4.0, 5.0, 6.0))
    
    
    def test_initializing_dimensions(self):
        class Dummy(BaseSection):
            dimensions = Dimensions(dim_a=5, dim_b=None)
        section1 = Dummy()
        section2 = Dummy(dim_a=3, dim_b=4)
        
        self.assertEqual(section1.dim_a, 5.0)
        self.assertRaises(ValueError, getattr, section1, "dim_b")
        
        self.assertEqual(section2.dim_a, 3.0)
        self.assertEqual(section2.dim_b, 4.0)
        self.assertIsInstance(section2.dim_a, float)
        self.assertIsInstance(section2.dim_b, float)
        
    
    def test_setting_dimensions(self):
        class Dummy(BaseSection):
            dimensions = Dimensions(dim_a=None, dim_b=None)

        section = Dummy()
        section.set_dimensions(dim_a=3, dim_b=4)

        self.assertEqual(section.dim_a, 3.0)
        self.assertEqual(section.dim_b, 4.0)
        self.assertIsInstance(section.dim_a, float)
        self.assertIsInstance(section.dim_b, float)
        self.assertRaises(AttributeError, setattr, section, "dim_a", 5)
        self.assertRaises(TypeError, section.set_dimensions, dim_a="abc")
        
        try:
            section.set_dimensions(dim_a="abc", dim_b=7)
        except:
            self.assertEqual(section.dim_a, 3.0)
            self.assertEqual(section.dim_b, 4.0)
        
        
    def test_delegating_dimensions(self):
        class Dummy(BaseSection):
            dimensions = Dimensions(dim_a=None, dim_b=None)
        section = Dummy()
        
        section.set_dimensions(dim_a=5, dim_b=6)
        self.assertEqual(section.dim_a, section.dimensions.dim_a)
        self.assertEqual(section.dim_b, section.dimensions.dim_b)
    

    def test_set_dimensions_calls_check_dimensions(self):
        def error_raiser():
            raise ValueError
        section = BaseSection()
        section.check_dimensions = error_raiser
            
        self.assertRaises(ValueError, section.set_dimensions)    	

    
    def test_vector_transformation(self):
        section = BaseSection()
        v1 = (2.0, 3.0)
        v2 = (0.0, 0.0)
        
        section.set_position(d1=-2.0, d2=0.0, theta=0.0)
        self.assertEqual(section.transform_to_global(v1), (0.0, 3.0))
        self.assertEqual(section.transform_to_global(v2), (-2.0, 0.0))
        
        section.set_position(d1=0.0, d2=-3.0, theta=0.0)<commit_msg>Corrected test for BaseSection.check_dimensions<commit_after>import unittest
from math import pi

from sections.core import BaseSection, Dimensions


class BaseSectionTests(unittest.TestCase):

    def test_initial_state(self):
        section = BaseSection()
        
        self.assertEqual(section.density, 1.0)
        self.assertEqual(section.position, (0.0, 0.0, 0.0))
        self.assertIsInstance(section.dimensions, Dimensions)
    
    
    def test_setting_density(self):
        section = BaseSection(density=2)
        
        self.assertRaises(AttributeError, setattr, section, "density", 3.0)
        self.assertEqual(section.density, 2.0)
        self.assertIsInstance(section.density, float)
        
        self.assertRaises(ValueError, section.set_density, "abc")
        self.assertRaises(ValueError, section.set_density, 0.0)

        section.set_density(3)
        self.assertEqual(section.density, 3.0)
        self.assertIsInstance(section.density, float)
        
    
    def test_setting_position(self):
        section = BaseSection()
        
        self.assertRaises(AttributeError, setattr, section, "position", (0, 0, 0))
        
        section.set_position(d1=1)
        self.assertIsInstance(section.position[0], float)
        self.assertEqual(section.position, (1.0, 0.0, 0.0))

        section.set_position(d2=2)
        self.assertIsInstance(section.position[1], float)
        self.assertEqual(section.position, (1.0, 2.0, 0.0))
        
        section.set_position(theta=3)
        self.assertIsInstance(section.position[2], float)
        self.assertEqual(section.position, (1.0, 2.0, 3.0))
        
        section.set_position(4, 5, 6)
        self.assertEqual(section.position, (4.0, 5.0, 6.0))
    
    
    def test_initializing_dimensions(self):
        class Dummy(BaseSection):
            dimensions = Dimensions(dim_a=5, dim_b=None)
        section1 = Dummy()
        section2 = Dummy(dim_a=3, dim_b=4)
        
        self.assertEqual(section1.dim_a, 5.0)
        self.assertRaises(ValueError, getattr, section1, "dim_b")
        
        self.assertEqual(section2.dim_a, 3.0)
        self.assertEqual(section2.dim_b, 4.0)
        self.assertIsInstance(section2.dim_a, float)
        self.assertIsInstance(section2.dim_b, float)
        
    
    def test_setting_dimensions(self):
        class Dummy(BaseSection):
            dimensions = Dimensions(dim_a=None, dim_b=None)

        section = Dummy()
        section.set_dimensions(dim_a=3, dim_b=4)

        self.assertEqual(section.dim_a, 3.0)
        self.assertEqual(section.dim_b, 4.0)
        self.assertIsInstance(section.dim_a, float)
        self.assertIsInstance(section.dim_b, float)
        self.assertRaises(AttributeError, setattr, section, "dim_a", 5)
        self.assertRaises(TypeError, section.set_dimensions, dim_a="abc")
        
        try:
            section.set_dimensions(dim_a="abc", dim_b=7)
        except:
            self.assertEqual(section.dim_a, 3.0)
            self.assertEqual(section.dim_b, 4.0)
        
        
    def test_delegating_dimensions(self):
        class Dummy(BaseSection):
            dimensions = Dimensions(dim_a=None, dim_b=None)
        section = Dummy()
        
        section.set_dimensions(dim_a=5, dim_b=6)
        self.assertEqual(section.dim_a, section.dimensions.dim_a)
        self.assertEqual(section.dim_b, section.dimensions.dim_b)
    

    def test_set_dimensions_calls_check_dimensions(self):
        def error_raiser(dims):
            raise ValueError
        section = BaseSection()
        section.check_dimensions = error_raiser
            
        self.assertRaises(ValueError, section.set_dimensions)    	

    
    def test_vector_transformation(self):
        section = BaseSection()
        v1 = (2.0, 3.0)
        v2 = (0.0, 0.0)
        
        section.set_position(d1=-2.0, d2=0.0, theta=0.0)
        self.assertEqual(section.transform_to_global(v1), (0.0, 3.0))
        self.assertEqual(section.transform_to_global(v2), (-2.0, 0.0))
        
        section.set_position(d1=0.0, d2=-3.0, theta=0.0)
{'fraction_non_alphanumeric': 0.11232239098481137, 'fraction_numerical': 0.030132288094071532, 'mean_word_length': 2.464149342384387, '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': '1651041', 'n_tokens_mistral': 2704, 'n_tokens_neox': 2628, 'n_words': 398}