-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_set_coordinations.py
36 lines (31 loc) · 1.2 KB
/
test_set_coordinations.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from create_particles import Particles
from simulation import simulation
import unittest
import numpy as np
import csv
import numpy.ma as ma
class Test_coordinates(unittest.TestCase):
def setUp(self):
n =100
self.xmax = 10
self.xmin = 0
self.ymax = 20
self.ymin = 0
particles = Particles('nazwa', n)
self.simulation = simulation(particles)
self.simulation.set_coordinations(n, self.xmax, self.xmin, self.ymax, self.ymin)
def test_x(self):
xarray = self.simulation.particles.coordinates[0]
test_array = np.where(xarray < self.xmax, xarray, 0)
test_array2 = np.where(self.xmin <= test_array, test_array, 0)
#print(test_array2)
#print(xarray)
self.assertTrue(np.array_equal(test_array2, self.simulation.particles.coordinates[0]))
def test_y(self):
xarray = self.simulation.particles.coordinates[1]
test_array = np.where(xarray < self.ymax, xarray, 0)
test_array2 = np.where(self.ymin <= test_array, test_array, 0)
#print(test_array)
self.assertTrue(np.array_equal(test_array2, self.simulation.particles.coordinates[1]))
if __name__ == '__main__':
unittest.main()