-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_simulation_test.py
62 lines (49 loc) · 2.49 KB
/
run_simulation_test.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import unittest
import numpy as np
from numba import njit
import plants.plant_creation as pc
import run_simulation.simulation as rs
import asset_generation.land_creation as lc
import line_profiler
profiler = line_profiler.LineProfiler()
class RunSimulationTest(unittest.TestCase):
def test_run_simulation(self):
world_params = {'world_size': 1000, 'global_creature_id_counter': int(0)}
world_params['plant_location_array'] = np.zeros(shape=(world_params['world_size'], world_params['world_size']), dtype=int)
world_params['occupied_squares_x'] = np.array([], dtype=int)
world_params['occupied_squares_y'] = np.array([], dtype=int)
world_params['occupied_squares_plant_id'] = np.array([], dtype=int)
world_params['carbon_dioxide_map'] = np.full(shape=(world_params['world_size'], world_params['world_size']), fill_value=0)
pc.spawn_new_plants(world_params=world_params, num_plants=1000)
rs.run_sim_for_x_steps(world_dict=world_params, steps=5000)
pass
# def test_old_2d_photosynthesis(self):
# plant_location_array = np.random.randint(0, 2, size=(200, 200), dtype=int)
# carbon_location_array = np.random.randint(0, 2, size=(200, 200), dtype=int)
# old_2d_photosynthesis(plant_location_array=plant_location_array,
# carbon_location_array=carbon_location_array)
#
# def test_nonzero_photosynthesis(self):
# plant_location_array = np.random.randint(0, 2, size=(200, 200), dtype=int)
# carbon_location_array = np.random.randint(0, 2, size=(200, 200), dtype=int)
# boolean_mask_of_both = nonzero_photosynthesis(plant_location_array=plant_location_array,
# carbon_location_array=carbon_location_array)
# profiler.print_stats()
#
#
# def old_2d_photosynthesis(plant_location_array, carbon_location_array):
# boolean_mask_of_plant_presence = plant_location_array > 0
# boolean_mask_of_carbon_presence = carbon_location_array > 0
# return np.logical_and(boolean_mask_of_carbon_presence, boolean_mask_of_plant_presence)
#
#
# def nonzero_photosynthesis(plant_location_array: np.ndarray, carbon_location_array: np.ndarray):
# return np.logical_and(plant_location_array, carbon_location_array)
#
#
# def new_1d_photosynthesis(plant_location_array, carbon_location_array):
# boolean_mask_of_plant_presence = plant_location_array > 0
# boolean_mask_of_carbon_presence = carbon_location_array > 0
# return np.logical_and(boolean_mask_of_carbon_presence, boolean_mask_of_plant_presence)
if __name__ == '__main__':
unittest.main()