Skip to content

Commit

Permalink
Modified unit test functionalities.
Browse files Browse the repository at this point in the history
  • Loading branch information
braden6521 committed Mar 25, 2024
1 parent 3cd2611 commit cc7a55c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
32 changes: 26 additions & 6 deletions opencsp/app/sofast/test/test_DisplayShape.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,39 +99,59 @@ def test_distorted3D(self):

def test_save_load_hdf_dist_3d(self):
# Instantiate display object
name = 'Test DisplayShape'
name = 'Test DisplayShape 3D'
disp = DisplayShape(self.grid_data_3D, name)
file = join(self.save_dir, 'test_display_shape_dist_3d.h5')

# Save
disp.save_to_hdf(file)

# Load
DisplayShape.load_from_hdf(file)
disp_load = DisplayShape.load_from_hdf(file)

# Compare
self.assertEqual(disp.grid_data['screen_model'], disp_load.grid_data['screen_model'])
self.assertEqual(disp.name, disp_load.name)
np.testing.assert_equal(
disp.grid_data['xy_screen_fraction'].data, disp_load.grid_data['xy_screen_fraction'].data)
np.testing.assert_equal(disp.grid_data['xyz_screen_coords'].data, disp_load.grid_data['xyz_screen_coords'].data)

def test_save_load_hdf_dist_2d(self):
# Instantiate display object
name = 'Test DisplayShape'
name = 'Test DisplayShape 2D'
disp = DisplayShape(self.grid_data_2D, name)
file = join(self.save_dir, 'test_display_shape_dist_2d.h5')

# Save
disp.save_to_hdf(file)

# Load
DisplayShape.load_from_hdf(file)
disp_load = DisplayShape.load_from_hdf(file)

# Compare
self.assertEqual(disp.grid_data['screen_model'], disp_load.grid_data['screen_model'])
self.assertEqual(disp.name, disp_load.name)
np.testing.assert_equal(
disp.grid_data['xy_screen_fraction'].data, disp_load.grid_data['xy_screen_fraction'].data)
np.testing.assert_equal(disp.grid_data['xy_screen_coords'].data, disp_load.grid_data['xy_screen_coords'].data)

def test_save_load_hdf_rectangular(self):
# Instantiate display object
name = 'Test DisplayShape'
name = 'Test DisplayShape Rectangular'
disp = DisplayShape(self.grid_data_rect2D, name)
file = join(self.save_dir, 'test_display_shape_rect.h5')

# Save
disp.save_to_hdf(file)

# Load
DisplayShape.load_from_hdf(file)
disp_load = DisplayShape.load_from_hdf(file)

# Compare
self.assertEqual(disp.grid_data['screen_model'], disp_load.grid_data['screen_model'])
self.assertEqual(disp.name, disp_load.name)
self.assertEqual(disp.grid_data['screen_x'], disp_load.grid_data['screen_x'])
self.assertEqual(disp.grid_data['screen_y'], disp_load.grid_data['screen_y'])


if __name__ == '__main__':
Expand Down
6 changes: 3 additions & 3 deletions opencsp/app/sofast/test/test_SpatialOrientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_io_oriented_optic(self):
# Load
ori = SpatialOrientation.load_from_hdf(file)
# Check optic is oriented
np.testing.assert_equal(ori.optic_oriented, True)
self.assertEqual(ori.optic_oriented, True)

def test_io_unoriented_optic(self):
file = join(self.save_dir, 'test_spatial_orientation_unoriented_optic.h5')
Expand All @@ -90,8 +90,8 @@ def test_io_unoriented_optic(self):
# Load
ori_2 = SpatialOrientation.load_from_hdf(file)
# Check optic not oriented
np.testing.assert_equal(ori_1.optic_oriented, False)
np.testing.assert_equal(ori_2.optic_oriented, False)
self.assertEqual(ori_1.optic_oriented, False)
self.assertEqual(ori_2.optic_oriented, False)


if __name__ == '__main__':
Expand Down

0 comments on commit cc7a55c

Please sign in to comment.