def test_bound(self):
        """
        Test bound vs unbound Particles
        """
        particle = Particle(Vector.rand(12), Vector.rand(12), 'test')
        self.assertFalse(particle.is_bound())
        self.assertIn('unbound', repr(particle))

        world = World(agents=[])
        world.add_agent(particle)
        self.assertTrue(particle.is_bound())
        self.assertIn('world', repr(particle))
    def test_bound(self):
        """
        Test bound vs unbound Particles
        """
        particle = Particle(Vector.rand(12), Vector.rand(12), 'test')
        self.assertFalse(particle.is_bound())
        self.assertIn('unbound', repr(particle))

        world = World(agents=[])
        world.add_agent(particle)
        self.assertTrue(particle.is_bound())
        self.assertIn('world', repr(particle))
    def test_periodic_find_closest(self):
        """
        Test that the find nearest can see periodic boundaries
        """
        agents = [
            Particle(Vector.arrp(10, 10), Vector.rand(6), 'a'),
            Particle(Vector.arrp(10, 990), Vector.rand(6), 'b'),
            Particle(Vector.arrp(990, 10), Vector.rand(6), 'c'),
            Particle(Vector.arrp(990, 990), Vector.rand(6), 'd'),
        ]
        world = World(agents=agents, world_size=1000)

        expected = world.agents[1]
        observed = world.agents[0].find_nearest(100, 360)
        self.assertEqual(expected, observed)
    def test_periodic_find_closest(self):
        """
        Test that the find nearest can see periodic boundaries
        """
        agents = [
            Particle(Vector.arrp(10, 10), Vector.rand(6), 'a'),
            Particle(Vector.arrp(10, 990), Vector.rand(6), 'b'),
            Particle(Vector.arrp(990, 10), Vector.rand(6), 'c'),
            Particle(Vector.arrp(990, 990), Vector.rand(6), 'd'),
        ]
        world = World(agents=agents, world_size=1000)

        expected = world.agents[1]
        observed = world.agents[0].find_nearest(100, 360)
        self.assertEqual(expected, observed)
    def test_periodic_neighborhood(self):
        """
        Test that the neighborhood can see periodic boundaries
        """
        agents = [
            Particle(Vector.arrp(10, 10), Vector.rand(6), 'a'),
            Particle(Vector.arrp(10, 990), Vector.rand(6), 'b'),
            Particle(Vector.arrp(990, 10), Vector.rand(6), 'c'),
            Particle(Vector.arrp(990, 990), Vector.rand(6), 'd'),
        ]
        world = World(agents=agents, world_size=1000)

        expected = {'b', 'c', 'd'}
        observed = set([])
        for neighbor in world.agents[0].neighbors(100, 360):
            observed.add(neighbor.idx)
        self.assertEqual(expected, observed)
    def test_periodic_neighborhood(self):
        """
        Test that the neighborhood can see periodic boundaries
        """
        agents = [
            Particle(Vector.arrp(10, 10), Vector.rand(6), 'a'),
            Particle(Vector.arrp(10, 990), Vector.rand(6), 'b'),
            Particle(Vector.arrp(990, 10), Vector.rand(6), 'c'),
            Particle(Vector.arrp(990, 990), Vector.rand(6), 'd'),
        ]
        world = World(agents=agents, world_size=1000)

        expected = {'b','c','d'}
        observed = set([])
        for neighbor in world.agents[0].neighbors(100, 360):
            observed.add(neighbor.idx)
        self.assertEqual(expected, observed)