Skip to content

Commit

Permalink
Fixed unit tests, made save dirs when necessary, sorted glob lists.
Browse files Browse the repository at this point in the history
  • Loading branch information
braden6521 committed Mar 21, 2024
1 parent 3e328b7 commit 1672d64
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions opencsp/app/sofast/test/test_CalibrateDisplayShape.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
"""Tests Sofast screen distortion calibration
"""

from os.path import join, dirname
from os.path import join
import unittest

from glob import glob
import numpy as np

from opencsp.common.lib.opencsp_path.opencsp_root_path import opencsp_code_dir
from opencsp.app.sofast.lib.CalibrateDisplayShape import CalibrateDisplayShape, DataInput
from opencsp.app.sofast.lib.MeasurementSofastFringe import MeasurementSofastFringe
from opencsp.common.lib.camera.Camera import Camera
from opencsp.common.lib.deflectometry.ImageProjection import ImageProjection
from opencsp.common.lib.geometry.Vxyz import Vxyz
from opencsp.common.lib.opencsp_path.opencsp_root_path import opencsp_code_dir
from opencsp.common.lib.tool.hdf5_tools import load_hdf5_datasets
import opencsp.common.lib.tool.file_tools as ft
import opencsp.common.lib.tool.log_tools as lt
Expand All @@ -27,7 +27,6 @@ def setUpClass(cls):
dir_input_sofast = join(opencsp_code_dir(), 'app/sofast/test/data/data_measurement')
dir_input_def = join(opencsp_code_dir(), 'common/lib/deflectometry/test/data/data_measurement')
dir_output = join(opencsp_code_dir(), 'app/sofast/test/data/data_expected')
ft.create_directories_if_necessary(dir_output)

# Define input files
resolution_xy = [100, 100] # sample density of screen
Expand All @@ -36,6 +35,7 @@ def setUpClass(cls):
file_camera_distortion = join(dir_input_sofast, 'camera_screen_shape.h5')
file_image_projection = join(dir_input_sofast, 'image_projection.h5')
files_screen_shape_measurement = glob(join(dir_input_sofast, 'screen_shape_sofast_measurements/pose_*.h5'))
files_screen_shape_measurement.sort()

# Load input data
pts_marker_data = np.loadtxt(file_point_locations, delimiter=',', dtype=float, skiprows=1)
Expand Down Expand Up @@ -67,6 +67,9 @@ def setUpClass(cls):
join(dir_output, 'screen_distortion_data_100_100.h5'),
)

cls.save_dir_local = join(opencsp_code_dir(), 'app/sofast/test/data/output')
ft.create_directories_if_necessary(cls.save_dir_local)

def test_xy_screen_fraction(self):
"""Tests xy points"""
data_meas = self.cal.get_data()
Expand All @@ -90,13 +93,13 @@ def test_xyz_screen_coords(self):
def test_save_display_object(self):
"""Tests saving DisplayShape object"""
display_shape = self.cal.as_DisplayShape('Test display')
file = join(dirname(__file__), 'data/output/test_calibration_display.h5')
file = join(self.save_dir_local, 'test_calibration_display.h5')
display_shape.save_to_hdf(file)


if __name__ == '__main__':
# Set up save dir
save_dir = join(dirname(__file__), 'data/output')
save_dir = join(opencsp_code_dir(), 'app/sofast/test/data/output')
ft.create_directories_if_necessary(save_dir)

# Set up logger
Expand Down
4 changes: 2 additions & 2 deletions opencsp/app/sofast/test/test_SpatialOrientation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Unit test suite to test the SpatialOrientation class"""

from os.path import join, dirname
from os.path import join
import unittest

import numpy as np
Expand Down Expand Up @@ -40,7 +40,7 @@ def setUpClass(cls):
cls.so = ori

# Set up save path
cls.save_dir = join(dirname(__file__), 'data/output')
cls.save_dir = join(opencsp_code_dir(), 'app/sofast/test/data/output')
ft.create_directories_if_necessary(cls.save_dir)

def test_translation_ring_1(self):
Expand Down

0 comments on commit 1672d64

Please sign in to comment.