<commit_before>#!/usr/python/bin
"""
Author: <NAME>
Particle class for Classwork 8
Defines particle objects that are seeded at initialization
and move around accordingly
"""
import numpy as np
from datetime import datetime

class Particle:
    """
    Defines particle objects that are seeded at initialization
and move around accordingly
    """
    def __init__(self, seed = datetime.now, x= 0, y = 0):
        self.x = x
        self.y = y
        self.RNG = np.random.RandomState(seed)
    
    def move(self, step_size = 1):
        """
        Moves in a random (seeded) direction with a distance of
        an optional stepsize
        """
        switch = RNG.randint(1, 5)
        if(switch == 1):
            y += step_size #Up
        elif(switch == 2):
            x += step_size #Right
        elif(switch == 3):
            y -= step_size #Down
        else:
            x -= step_size #left

    def test_confined_movement():
        """
        Given n number of steps, the particles
        should not deviate n units from the origin
        n = [10, 100, 1000]
        """
        n = [10, 100, 1000]
        p = Particle()
        for x in xrange(n[0]):
            p.move()
        p = Particle()
        for x in xrange(n[0]):
            p.move()
        
        
        <commit_msg>Particle should be working now<commit_after>#!/usr/python/bin
"""
Author: <NAME>
Particle class for Classwork 8
Defines particle objects that are seeded at initialization
and move around accordingly
"""
import numpy as np
import time
from unittest import TestCase

class Particle:
    """
    Defines particle objects that are seeded at initialization
and move around accordingly
    """
    def __init__(self, seed = int(time.time()*10000), x= 0, y = 0):
        self.x = x
        self.y = y
        self.RNG = np.random.seed(seed)

    def move(self, step_size = 1):
        """
        Moves in a random (seeded) direction with a distance of
        an optional stepsize
        """
        switch = RNG.randint(1, 5)
        if(switch == 1):
            y += step_size #Up
        elif(switch == 2):
            x += step_size #Right
        elif(switch == 3):
            y -= step_size #Down
        else:
            x -= step_size #left

class test_Particle(TestCase):
    """
    Test Class for Particle.
    This class only extends with test functions
    """

    
    def test_confined_movement():
        """
        Given n number of steps, the particles
        should not deviate n units from the origin
        n = [10, 100, 1000]
        """
        n = [10, 100, 1000]
        testReturn = True
        for numberOfSteps in n:
            p = Particle()
            for x in xrange(numberOfSteps):
                p.move()
            if(p.x > numberOfSteps or p.x < (-1 * numberOfSteps) or p.y > numberOfSteps or p.y < (-1 * numberOfSteps)):
                testReturn = False
        assert(testReturn)

    def test_same_seed_movement(numberOfSteps = 100000):
        """
        2 Particles given the same seed should move identically
        We test that all positions of the two particles are identical
        to the numberOfSteps specified
        """
        p1 = Particle(1024901)
        p2 = Particle(1024901)
        testReturn = True
        for x in xrange(numberOfSteps):
            p1.move()
            p2.move()
            if(p1.x != p2.x or p1.y != p2.y):
                testReturn = False
        assert(testReturn)
{'fraction_non_alphanumeric': 0.09521061742642815, 'fraction_numerical': 0.026543566070398154, 'mean_word_length': 1.8095623987034035, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5026826', 'n_tokens_mistral': 1079, 'n_tokens_neox': 996, 'n_words': 349}