def test_descending_particle_number(self): """testing if the particle number thing works in this class too in the descending manner; it should be correctly inherited from the parent class 'Particle' """ particle1 = base_classes.Clay( x=0, y=0, inclination=np.math.pi / 4, thickness=1, length=100, ) particle2 = base_classes.Clay( x=1, y=1, inclination=np.math.pi / 4, thickness=1, length=100, ) del particle2 self.assertEqual(base_classes.Particle.last_num, particle1.num + 1) particle3 = base_classes.Clay( x=1, y=1, inclination=np.math.pi / 4, thickness=1, length=100, ) self.assertEqual(particle1.num + 1, particle3.num)
def test_equality_condition(self): """testing if the equality condition works here to; it is inherited from the parent class 'Particle' """ particle1 = base_classes.Clay( x=0, y=0, inclination=np.math.pi / 4, thickness=1, length=100, ) particle2 = base_classes.Clay( x=0, y=0, inclination=np.math.pi / 4, thickness=1, length=100, ) self.assertNotEqual(particle1, particle2)
def test_standardizing_inclination1(self): """testing if a non-standard given inclination becomes standard """ particle = base_classes.Clay( x=501, y=74, inclination=3 * np.math.pi / 2, thickness=1, length=100, ) self.assertEqual(particle.inclination, np.math.pi / 2)
def test_midline(self): """testing if the midline attribute of the Clay instance is created correctly """ particle = base_classes.Clay( x=0, y=0, inclination=np.math.pi / 4, thickness=1, length=20 * np.sqrt(2), ) line = shapes.LineSegment(shapes.Point(-10, -10), shapes.Point(10, 10))
def test_midpoint(self): """testing if the midpoint attribute of the Clay instance is created correctly """ particle = base_classes.Clay( x=501, y=74, inclination=-1 * np.math.pi / 6, thickness=1, length=100, ) self.assertEqual(particle.midpoint, shapes.Point(501, 74))
def test_standardizing_inclination2(self): """testing if a non-standard given inclination becomes standard with a negative inclination given """ particle = base_classes.Clay( x=501, y=74, inclination=-1 * np.math.pi / 6, thickness=1, length=100, ) self.assertAlmostEqual(particle.inclination, 5 * np.math.pi / 6)
def test_box_num(self): """testing if the box_number method works here too; it is inherited from the parent class 'Particle' """ particle = base_classes.Clay( x=501, y=74, inclination=np.math.pi / 4, thickness=1, length=100, ) bn = particle.box_num(nc=100, box_length=10, box_width=10) self.assertEqual(bn, 750)
def test_hashable(self): """testing if the particle being hashable works here too; it is inherited from the parent class 'Particle' """ particle = base_classes.Clay( x=0, y=0, inclination=np.math.pi / 4, thickness=1, length=100, ) s = {particle} self.assertTrue(s)
def test_shape(self): """testing if the 'shape' attribute of the Clay instance is created correctly """ particle = base_classes.Clay( x=0, y=0, inclination=np.math.pi / 4, thickness=20 * np.sqrt(2), length=20 * np.sqrt(2), ) v1 = shapes.Point(-20, 0) v2 = shapes.Point(0, -20) v3 = shapes.Point(20, 0) v4 = shapes.Point(0, 20) rec = shapes.Rectangle(v1, v2, v3, v4) self.assertEqual(particle.shape, rec)
def test_attribute_assigning(self): """testing if all the attributes that a Clay instance should contain are present here; this also includes all the attributes and properties of the parent class 'Particle' """ particle = base_classes.Clay( x=501, y=74, inclination=-1 * np.math.pi / 6, thickness=1, length=100, ) self.assertEqual(particle.x, 501) self.assertEqual(particle.y, 74) self.assertAlmostEqual(particle.inclination, 5 * np.math.pi / 6) self.assertEqual(particle.thickness, 1) self.assertEqual(particle.length, 100) self.assertFalse(particle.is_segment) self.assertTrue(particle.midline) self.assertTrue(particle.midpoint) self.assertTrue(particle.segments)
def test_segmentalize(self): """testing if the 'segments' attribute of the Clay instance is created correctly using the 'segmentalize' method of the class; it should generate three segments which all have the same 'num' attribute; also testing if the next created particle comes with a correct 'num' attribute """ particle = base_classes.Clay( x=0, y=0, inclination=np.math.pi / 4, thickness=1, length=6 * np.sqrt(2), ) self.assertEqual(len(particle.segments), 3) for seg in particle.segments: self.assertTrue(seg.is_segment) self.assertEqual(particle.segments[1].midpoint, shapes.Point(0, 0)) self.assertEqual(particle.segments[0].length, 2 * np.sqrt(2)) self.assertEqual( particle.segments[2].midline, shapes.LineSegment(shapes.Point(1, 1), shapes.Point(3, 3)))