def test_system(self): system = System(name='MyNewSystem') system.put_space((5, 5, 5), space_factor_types=[i for i in SpaceFactor]) light = Light(uuid=uuid.uuid4()) system.put_entity(light, (0, 0, 0)) self.assertRaises(TypeError, lambda: pickle.dumps(system)) light.destroy()
class TestLightCompute(TestLightTasked): def setUp(self): super().setUp() self.light = Light(uuid=uuid.uuid4(), selected_functions=(Function.POWERED, Function.TASKED, Function.COMPUTE)) def tearDown(self): self.light.destroy() super().tearDown()
def test_main_7(self): # Create System self.system = System('MyNewSystem') # Put Space on the System self.system.put_space( dimension=(40, 30, 12), resolution=1, space_factor_types=[i for i in SpaceFactor.SpaceFactor]) # Put Entity on the Space power_supply = PowerSupply(uuid=uuid.uuid4()) light_switch1 = Switch(uuid=uuid.uuid4()) wire_ls1 = PowerWire(power_supply, light_switch1) light1 = Light(uuid=uuid.uuid4()) wire_l1 = PowerWire(light_switch1, light1) self.system.put_entity(power_supply, (19, 14, 9)) self.system.put_entity(light_switch1, (19, 14, 9)) self.system.put_entity(light1, (9, 14, 9)) power_supply.send_task(SystemTask(TaskName.ACTIVE)) light_switch1.send_task(SystemTask(TaskName.ACTIVE)) light1.send_task(SystemTask(TaskName.ACTIVE)) light1.send_task( SystemTask(TaskName.ACTUATE, value={ 'space': self.system.space, 'location': self.system.entities[2][1], 'orientation': self.system.entities[2][1] })) res = light1.recv_task_resp() luminosity = npx.char.mod( 'hsl(%d,%d%,%d%)', (res.value[SpaceFactor.SpaceFactor.LUMINOSITY][ SpaceFactor.Luminosity.HUE], res.value[SpaceFactor.SpaceFactor.LUMINOSITY][ SpaceFactor.Luminosity.SATURATION], res.value[SpaceFactor.SpaceFactor.LUMINOSITY][ SpaceFactor.Luminosity.BRIGHTNESS])) Plotter.plot_scatter_3d( array3d=luminosity, zero_value=-1, filename=os.path.join( test_settings.actual_path, self._testMethodName + '_luminosity_plot.html'), auto_open=True, opacity=0.6) light1.destroy()
def test_main_2(self): # Create System self.system = System('MyNewSystem') # Put Space on the System self.system.put_space( dimension=(40, 30, 10), resolution=1, space_factor_types=[i for i in SpaceFactor.SpaceFactor]) # Put Entity on the Space table1 = Table(uuid=uuid.uuid4(), dimension_x=(2, 1, 1)) self.system.put_entity(table1, (0, 0, 0)) light1 = Light(uuid=uuid.uuid4(), dimension_x=(1, 1, 1)) self.system.put_entity(light1, (19, 14, 7)) ac1 = AirConditioner(uuid=uuid.uuid4()) self.system.put_entity(ac1, (37, 10, 7), unit_orientation=(-1, 0, 0)) sd1 = SmokeDetector(uuid=uuid.uuid4()) self.system.put_entity(sd1, (0, 10, 8), unit_orientation=(1, 0, 0)) thermostat1 = Thermostat(uuid=uuid.uuid4()) self.system.put_entity(thermostat1, (30, 0, 5)) # Compare Space Factor Matter np.save( os.path.join(test_settings.actual_path, self._testMethodName + '_space_matter.npy'), self.system.space.space_factors[SpaceFactor.SpaceFactor.MATTER][ SpaceFactor.Matter.MATTER]) np.testing.assert_array_equal( np.load( os.path.join(test_settings.expected_path, self._testMethodName + '_space_matter.npy')), self.system.space.space_factors[SpaceFactor.SpaceFactor.MATTER][ SpaceFactor.Matter.MATTER]) # Plot Plotter.plot_scatter_3d( array3d=self.system.space.space_factors[ SpaceFactor.SpaceFactor.MATTER][SpaceFactor.Matter.MATTER], zero_value=SpaceFactor.MatterType.ATMOSPHERE.value, filename=os.path.join(test_settings.actual_path, self._testMethodName + '_matter_plot.html'), auto_open=test_settings.auto_open) light1.destroy()
def test_put_entity(self): # Put Space self.system.put_space(dimension=self.dimension, resolution=self.resolution, space_factor_types=[SpaceFactor.MATTER]) # Put Entity on the Space self.assertEqual(0, len(self.system.entities)) table1 = Table(uuid=uuid.uuid4()) self.system.put_entity(table1, (0, 0, 0)) self.assertEqual(1, len(self.system.entities)) self.assertTrue((table1, (0, 0, 0), None) in self.system.entities) light1 = Light(uuid=uuid.uuid4()) self.system.put_entity(light1, (1, 1, 1)) self.assertEqual(2, len(self.system.entities)) self.assertTrue((table1, (0, 0, 0), None) in self.system.entities) self.assertTrue((light1, (1, 1, 1), None) in self.system.entities) light1.destroy()
def test_input_power(self): def check_active(l_light, expected): if expected: self.assertTrue(l_light.active) else: self.assertFalse(l_light.active) light = Light(uuid=uuid.uuid4(), selected_functions=(Function.POWERED, )) check_active(light, False) light.get_function(Function.POWERED).get_power_input().set_power( ElectricPower(110)) check_active(light, True) light.get_function(Function.POWERED).get_power_input().set_power( ElectricPower(220)) check_active(light, False)
def setUp(self): super().setUp() self.light = Light(uuid=uuid.uuid4(), selected_functions=(Function.POWERED, Function.TASKED))
class TestLightTasked(TestLightPowered): def setUp(self): super().setUp() self.light = Light(uuid=uuid.uuid4(), selected_functions=(Function.POWERED, Function.TASKED)) def test_send_task(self): # SystemTask self.light.send_task(SystemTask(name=TaskName.ACTIVE)) # EntityTask self.light.send_task(Task(name=TaskName.GET_INFO)) def test_recv_task_resp(self): self.light.send_task( SystemTask(name=TaskName.SET_POWER, value={'power': ElectricPower(110)})) self.assertEqual(TaskResponse(Status.OK), self.light.recv_task_resp()) self.light.send_task(SystemTask(name=TaskName.ACTIVE)) self.assertEqual(TaskResponse(Status.OK), self.light.recv_task_resp()) self.light.send_task(Task(name=TaskName.GET_INFO)) self.assertEqual( TaskResponse(status=Status.OK, value={ 'info': { 'uuid': str(self.light.uuid), 'identifier': type(self.light).identifier, 'type': { 'actuator': ['POWER'], 'sensor': [], 'accessor': [] }, } }), self.light.recv_task_resp()) def test_active_deactivate(self): self.light.send_task( SystemTask(name=TaskName.SET_POWER, value={'power': ElectricPower(110)})) self.assertEqual(self.light.recv_task_resp(), TaskResponse(status=Status.OK, value=None)) self.light.send_task(SystemTask(name=TaskName.DEACTIVATE)) self.assertEqual(self.light.recv_task_resp(), TaskResponse(status=Status.OK, value=None)) self.light.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertFalse( self.light.recv_task_resp().value['system_info']['active']) self.light.send_task(SystemTask(name=TaskName.ACTIVE)) self.assertEqual(self.light.recv_task_resp(), TaskResponse(status=Status.OK, value=None)) self.light.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertTrue( self.light.recv_task_resp().value['system_info']['active']) self.light.send_task(SystemTask(name=TaskName.DEACTIVATE)) self.assertEqual(self.light.recv_task_resp(), TaskResponse(status=Status.OK, value=None)) self.light.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertFalse( self.light.recv_task_resp().value['system_info']['active']) self.light.send_task(Task(name=TaskName.GET_INFO)) self.assertEqual( self.light.recv_task_resp(), TaskResponse(status=Status.OK, value={ 'info': { 'uuid': str(self.light.uuid), 'identifier': type(self.light).identifier, 'type': { 'actuator': ['POWER'], 'sensor': [], 'accessor': [] }, } })) self.light.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertFalse( self.light.recv_task_resp().value['system_info']['active']) self.light.send_task(SystemTask(name=TaskName.DEACTIVATE)) self.assertEqual(self.light.recv_task_resp(), TaskResponse(status=Status.OK, value=None)) self.light.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertFalse( self.light.recv_task_resp().value['system_info']['active']) self.light.send_task(SystemTask(name=TaskName.ACTIVE)) self.assertEqual(self.light.recv_task_resp(), TaskResponse(status=Status.OK, value=None)) self.light.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertTrue( self.light.recv_task_resp().value['system_info']['active']) self.light.send_task(Task(name=TaskName.GET_INFO)) self.assertEqual( self.light.recv_task_resp(), TaskResponse(status=Status.OK, value={ 'info': { 'uuid': str(self.light.uuid), 'identifier': type(self.light).identifier, 'type': { 'actuator': ['POWER'], 'sensor': [], 'accessor': [] }, } })) def test_input_power(self): def check_active(l_light, expected): if expected: self.assertTrue(l_light.active) else: self.assertFalse(l_light.active) light = Light(uuid=uuid.uuid4(), selected_functions=(Function.POWERED, )) check_active(light, False) light.get_function(Function.POWERED).get_power_input().set_power( ElectricPower(110)) check_active(light, True) light.get_function(Function.POWERED).get_power_input().set_power( ElectricPower(220)) check_active(light, False) def test_input_power_autodeactivate(self): def check_active(l_light, expected): if expected: self.assertTrue(l_light.active) l_light.send_task(SystemTask(TaskName.GET_SYSTEM_INFO)) self.assertTrue( light.recv_task_resp().value['system_info']['active']) else: self.assertFalse(l_light.active) l_light.send_task(SystemTask(TaskName.GET_SYSTEM_INFO)) self.assertFalse( light.recv_task_resp().value['system_info']['active']) light = Light(uuid=uuid.uuid4(), selected_functions=(Function.POWERED, Function.TASKED)) check_active(light, False) light.send_task(SystemTask(TaskName.ACTIVE)) light.recv_task_resp() check_active(light, False) light.send_task( SystemTask(TaskName.SET_POWER, value={'power': ElectricPower(110)})) light.send_task(SystemTask(TaskName.ACTIVE)) light.recv_task_resp() check_active(light, True) light.send_task( SystemTask(TaskName.SET_POWER, value={'power': ElectricPower(0)})) check_active(light, False) light.send_task(SystemTask(TaskName.ACTIVE)) light.recv_task_resp() check_active(light, False) light.send_task( SystemTask(TaskName.SET_POWER, value={'power': ElectricPower(220)})) check_active(light, False) light.send_task(SystemTask(TaskName.ACTIVE)) light.recv_task_resp() check_active(light, False)
def test_input_power_autodeactivate(self): def check_active(l_light, expected): if expected: self.assertTrue(l_light.active) l_light.send_task(SystemTask(TaskName.GET_SYSTEM_INFO)) self.assertTrue( light.recv_task_resp().value['system_info']['active']) else: self.assertFalse(l_light.active) l_light.send_task(SystemTask(TaskName.GET_SYSTEM_INFO)) self.assertFalse( light.recv_task_resp().value['system_info']['active']) light = Light(uuid=uuid.uuid4(), selected_functions=(Function.POWERED, Function.TASKED)) check_active(light, False) light.send_task(SystemTask(TaskName.ACTIVE)) light.recv_task_resp() check_active(light, False) light.send_task( SystemTask(TaskName.SET_POWER, value={'power': ElectricPower(110)})) light.send_task(SystemTask(TaskName.ACTIVE)) light.recv_task_resp() check_active(light, True) light.send_task( SystemTask(TaskName.SET_POWER, value={'power': ElectricPower(0)})) check_active(light, False) light.send_task(SystemTask(TaskName.ACTIVE)) light.recv_task_resp() check_active(light, False) light.send_task( SystemTask(TaskName.SET_POWER, value={'power': ElectricPower(220)})) check_active(light, False) light.send_task(SystemTask(TaskName.ACTIVE)) light.recv_task_resp() check_active(light, False)
class TestLightPowered(AppTestCase): def setUp(self): super().setUp() self.light = Light(uuid=uuid.uuid4(), selected_functions=(Function.POWERED, )) def tearDown(self): self.logger.info(test_settings.end_title_format(self._testMethodName)) self.logger.info('') def test_get_default_shape(self): self.assertEqual(self.light.get_default_shape().shape, (3, 3, 3)) matter = MatterType.GLASS.value np.testing.assert_array_equal( self.light.get_default_shape(), [[[0, 0, 0], [0, matter, 0], [0, 0, 0]], [[0, matter, 0], [matter, matter, matter], [0, matter, 0]], [[0, 0, 0], [0, matter, 0], [0, 0, 0]]]) def test_send_task(self): # SystemTask self.assertRaises( FunctionUnsupportedError, lambda: self.light.send_task(SystemTask(name=TaskName.ACTIVE))) # EntityTask self.assertRaises( FunctionUnsupportedError, lambda: self.light.send_task(Task(name=TaskName.GET_INFO))) # ProgramTask self.assertRaises( FunctionUnsupportedError, lambda: self.light.send_task(ProgramTask(name=TaskName.END))) def test_recv_task_resp(self): self.assertRaises( FunctionUnsupportedError, lambda: self.light.send_task( SystemTask(name=TaskName.SET_POWER, value={'power': ElectricPower(110)}))) self.assertRaises(FunctionUnsupportedError, lambda: self.light.recv_task_resp()) # SystemTask self.assertRaises( FunctionUnsupportedError, lambda: self.light.send_task(SystemTask(name=TaskName.ACTIVE))) self.assertRaises(FunctionUnsupportedError, lambda: self.light.recv_task_resp()) # EntityTask self.assertRaises( FunctionUnsupportedError, lambda: self.light.send_task(Task(name=TaskName.GET_INFO))) self.assertRaises(FunctionUnsupportedError, lambda: self.light.recv_task_resp())
def test_light(self): light = Light(uuid=uuid.uuid4()) self.assertRaises(TypeError, lambda: pickle.dumps(light)) light.destroy()
def test_main_6(self): # Create System self.system = System('MyNewSystem') # Put Space on the System self.system.put_space( dimension=(40, 30, 12), resolution=1, space_factor_types=[i for i in SpaceFactor.SpaceFactor]) # Put Entity on the Space power_supply = PowerSupply(uuid=uuid.uuid4()) light_switch1 = Switch(uuid=uuid.uuid4()) wire_ls1 = PowerWire(power_supply, light_switch1) light1 = Light(uuid=uuid.uuid4(), selected_functions=(Function.POWERED, )) wire_l1 = PowerWire(light_switch1, light1) light_switch2 = Switch(uuid=uuid.uuid4()) wire_ls2 = PowerWire(power_supply, light_switch2) light2 = Light(uuid=uuid.uuid4(), selected_functions=(Function.POWERED, )) wire_l2 = PowerWire(light_switch2, light2) power_supply.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertFalse( power_supply.recv_task_resp().value['system_info']['active']) light_switch1.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertFalse( light_switch1.recv_task_resp().value['system_info']['active']) self.assertFalse(light1.active) light_switch2.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertFalse( light_switch2.recv_task_resp().value['system_info']['active']) self.assertFalse(light2.active) # Turn On PowerSupply power_supply.send_task(SystemTask(name=TaskName.ACTIVE)) self.assertEqual(TaskResponse(status=Status.OK, value=None), power_supply.recv_task_resp()) power_supply.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertTrue( power_supply.recv_task_resp().value['system_info']['active']) light_switch1.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertFalse( light_switch1.recv_task_resp().value['system_info']['active']) self.assertFalse(light1.active) light_switch2.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertFalse( light_switch2.recv_task_resp().value['system_info']['active']) self.assertFalse(light2.active) # Turn On Switch light_switch1.send_task(SystemTask(name=TaskName.ACTIVE)) self.assertEqual(TaskResponse(status=Status.OK, value=None), light_switch1.recv_task_resp()) power_supply.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertTrue( power_supply.recv_task_resp().value['system_info']['active']) light_switch1.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertTrue( light_switch1.recv_task_resp().value['system_info']['active']) self.assertTrue(light1.active) light_switch2.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertFalse( light_switch2.recv_task_resp().value['system_info']['active']) self.assertFalse(light2.active) light_switch2.send_task(SystemTask(name=TaskName.ACTIVE)) self.assertEqual(TaskResponse(status=Status.OK, value=None), light_switch2.recv_task_resp()) power_supply.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertTrue( power_supply.recv_task_resp().value['system_info']['active']) light_switch1.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertTrue( light_switch1.recv_task_resp().value['system_info']['active']) self.assertTrue(light1.active) light_switch2.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertTrue( light_switch2.recv_task_resp().value['system_info']['active']) self.assertTrue(light2.active) # Turn Off Switch light_switch1.send_task(SystemTask(name=TaskName.DEACTIVATE)) self.assertEqual(TaskResponse(status=Status.OK, value=None), light_switch1.recv_task_resp()) power_supply.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertTrue( power_supply.recv_task_resp().value['system_info']['active']) light_switch1.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertFalse( light_switch1.recv_task_resp().value['system_info']['active']) self.assertFalse(light1.active) light_switch2.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertTrue( light_switch2.recv_task_resp().value['system_info']['active']) self.assertTrue(light2.active) light_switch2.send_task(SystemTask(name=TaskName.DEACTIVATE)) self.assertEqual(TaskResponse(status=Status.OK, value=None), light_switch2.recv_task_resp()) power_supply.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertTrue( power_supply.recv_task_resp().value['system_info']['active']) light_switch1.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertFalse( light_switch1.recv_task_resp().value['system_info']['active']) self.assertFalse(light1.active) light_switch2.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO)) self.assertFalse( light_switch2.recv_task_resp().value['system_info']['active']) self.assertFalse(light2.active) power_supply.destroy() light_switch1.destroy() light_switch2.destroy() light1.destroy() light2.destroy()
def test_main_3(self): # Create System self.system = System('MyNewSystem') # Put Space on the System self.system.put_space( dimension=(40, 30, 12), resolution=1, space_factor_types=[i for i in SpaceFactor.SpaceFactor]) # Put Entity on the Space table1 = Table(uuid=uuid.uuid4(), dimension_x=(2, 1, 1)) light1 = Light(uuid=uuid.uuid4(), dimension_x=(1, 1, 1)) ac1 = AirConditioner(uuid=uuid.uuid4()) sd1 = SmokeDetector(uuid=uuid.uuid4()) thermostat1 = Thermostat(uuid=uuid.uuid4()) ch1 = Chair(uuid=uuid.uuid4()) h1 = Human(uuid=uuid.uuid4()) w1 = Wardrobe(uuid=uuid.uuid4()) self.system.put_entity(table1, (0, 0, 0)) self.system.put_entity(light1, (19, 14, 9)) self.system.put_entity(ac1, (37, 10, 9), unit_orientation=(-1, 0, 0)) self.system.put_entity(sd1, (10, 10, 11), unit_orientation=(0, 0, -1)) self.system.put_entity(thermostat1, (30, 0, 5)) self.system.put_entity(ch1, (4, 4, 0), unit_orientation=(0, -1, 0)) self.system.put_entity(h1, (25, 20, 0), unit_orientation=(0, -1, 0)) self.system.put_entity(w1, (0, 20, 0), unit_orientation=(1, 0, 0)) # Compare Space Factors np.save( os.path.join(test_settings.actual_path, self._testMethodName + '_space_matter.npy'), self.system.space.space_factors[SpaceFactor.SpaceFactor.MATTER][ SpaceFactor.Matter.MATTER]) np.save( os.path.join(test_settings.actual_path, self._testMethodName + '_space_temperature.npy'), self.system.space.space_factors[ SpaceFactor.SpaceFactor.TEMPERATURE][ SpaceFactor.Temperature.TEMPERATURE]) np.save( os.path.join(test_settings.actual_path, self._testMethodName + '_space_humidity.npy'), self.system.space.space_factors[SpaceFactor.SpaceFactor.HUMIDITY][ SpaceFactor.Humidity.HUMIDITY]) np.save( os.path.join(test_settings.actual_path, self._testMethodName + '_space_hue.npy'), self.system.space.space_factors[SpaceFactor.SpaceFactor.LUMINOSITY] [SpaceFactor.Luminosity.HUE]) np.save( os.path.join(test_settings.actual_path, self._testMethodName + '_space_saturation.npy'), self.system.space.space_factors[SpaceFactor.SpaceFactor.LUMINOSITY] [SpaceFactor.Luminosity.SATURATION]) np.save( os.path.join(test_settings.actual_path, self._testMethodName + '_space_brightness.npy'), self.system.space.space_factors[SpaceFactor.SpaceFactor.LUMINOSITY] [SpaceFactor.Luminosity.BRIGHTNESS]) np.save( os.path.join(test_settings.actual_path, self._testMethodName + '_space_air_x.npy'), self.system.space.space_factors[ SpaceFactor.SpaceFactor.AIR_MOVEMENT][ SpaceFactor.AirMovement.X]) np.save( os.path.join(test_settings.actual_path, self._testMethodName + '_space_air_y.npy'), self.system.space.space_factors[ SpaceFactor.SpaceFactor.AIR_MOVEMENT][ SpaceFactor.AirMovement.Y]) np.save( os.path.join(test_settings.actual_path, self._testMethodName + '_space_air_z.npy'), self.system.space.space_factors[ SpaceFactor.SpaceFactor.AIR_MOVEMENT][ SpaceFactor.AirMovement.Z]) np.testing.assert_array_equal( np.load( os.path.join(test_settings.expected_path, self._testMethodName + '_space_matter.npy')), self.system.space.space_factors[SpaceFactor.SpaceFactor.MATTER][ SpaceFactor.Matter.MATTER]) np.testing.assert_array_equal( np.load( os.path.join(test_settings.expected_path, self._testMethodName + '_space_temperature.npy')), self.system.space.space_factors[ SpaceFactor.SpaceFactor.TEMPERATURE][ SpaceFactor.Temperature.TEMPERATURE]) np.testing.assert_array_equal( np.load( os.path.join(test_settings.expected_path, self._testMethodName + '_space_humidity.npy')), self.system.space.space_factors[SpaceFactor.SpaceFactor.HUMIDITY][ SpaceFactor.Humidity.HUMIDITY]) np.testing.assert_array_equal( np.load( os.path.join(test_settings.expected_path, self._testMethodName + '_space_hue.npy')), self.system.space.space_factors[SpaceFactor.SpaceFactor.LUMINOSITY] [SpaceFactor.Luminosity.HUE]) np.testing.assert_array_equal( np.load( os.path.join(test_settings.expected_path, self._testMethodName + '_space_saturation.npy')), self.system.space.space_factors[SpaceFactor.SpaceFactor.LUMINOSITY] [SpaceFactor.Luminosity.SATURATION]) np.testing.assert_array_equal( np.load( os.path.join(test_settings.expected_path, self._testMethodName + '_space_brightness.npy')), self.system.space.space_factors[SpaceFactor.SpaceFactor.LUMINOSITY] [SpaceFactor.Luminosity.BRIGHTNESS]) np.testing.assert_array_equal( np.load( os.path.join(test_settings.expected_path, self._testMethodName + '_space_air_x.npy')), self.system.space.space_factors[ SpaceFactor.SpaceFactor.AIR_MOVEMENT][ SpaceFactor.AirMovement.X]) np.testing.assert_array_equal( np.load( os.path.join(test_settings.expected_path, self._testMethodName + '_space_air_y.npy')), self.system.space.space_factors[ SpaceFactor.SpaceFactor.AIR_MOVEMENT][ SpaceFactor.AirMovement.Y]) np.testing.assert_array_equal( np.load( os.path.join(test_settings.expected_path, self._testMethodName + '_space_air_z.npy')), self.system.space.space_factors[ SpaceFactor.SpaceFactor.AIR_MOVEMENT][ SpaceFactor.AirMovement.Z]) # Plot Plotter.plot_scatter_3d( array3d=self.system.space.space_factors[ SpaceFactor.SpaceFactor.MATTER][SpaceFactor.Matter.MATTER], zero_value=SpaceFactor.MatterType.ATMOSPHERE.value, filename=os.path.join(test_settings.actual_path, self._testMethodName + '_matter_plot.html'), auto_open=test_settings.auto_open) x_dark, y_dark, z_dark = (self.system.space.space_factors[ SpaceFactor.SpaceFactor.MATTER][SpaceFactor.Matter.MATTER] > 300).nonzero() for i in range(len(x_dark)): self.system.space.space_factors[ SpaceFactor.SpaceFactor.LUMINOSITY][ SpaceFactor.Luminosity.BRIGHTNESS][x_dark[i], y_dark[i], z_dark[i]] = 0 self.system.space.space_factors[SpaceFactor.SpaceFactor.LUMINOSITY][ SpaceFactor.Luminosity.BRIGHTNESS][0:3, 20:25, 0:7] = 0 self.system.space.space_factors[SpaceFactor.SpaceFactor.LUMINOSITY][ SpaceFactor.Luminosity.BRIGHTNESS][0:9, 0:3, 0:3] = 0 luminosity = npx.char.mod('hsl(%d,%d%,%d%)', ( self.system.space.space_factors[SpaceFactor.SpaceFactor.LUMINOSITY] [SpaceFactor.Luminosity.HUE], self.system.space.space_factors[SpaceFactor.SpaceFactor.LUMINOSITY] [SpaceFactor.Luminosity.SATURATION], self.system.space.space_factors[SpaceFactor.SpaceFactor.LUMINOSITY] [SpaceFactor.Luminosity.BRIGHTNESS])) Plotter.plot_scatter_3d( array3d=luminosity, zero_value=-1, filename=os.path.join( test_settings.actual_path, self._testMethodName + '_luminosity_plot.html'), auto_open=test_settings.auto_open, opacity=0.6) light1.destroy()