Skip to content

Commit

Permalink
Check opencsp.app for doc strings
Browse files Browse the repository at this point in the history
  • Loading branch information
e10harvey committed Oct 31, 2024
1 parent 679d5b4 commit 1f45058
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 36 deletions.
3 changes: 2 additions & 1 deletion opencsp/app/camera_calibration/lib/ViewAnnotatedImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@


class ViewAnnotatedImages:
"""Class that controls a window used to view images with a next and previous
"""
Class that controls a window used to view images with a next and previous
button
"""

Expand Down
3 changes: 2 additions & 1 deletion opencsp/app/sofast/lib/ImageCalibrationAbstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ def calculate_min_display_camera_values(self, derivative_thresh: float = 0.4) ->
return (display_min_value, camera_min_value)

def plot_gray_levels(self) -> None:
"""Shows plot of gray levels calibration data. When the close() method of this instance is called (or this
"""
Shows plot of gray levels calibration data. When the close() method of this instance is called (or this
instance is destructed), the plot will be closed automatically."""
title = 'Projector-Camera Calibration Curve'

Expand Down
4 changes: 3 additions & 1 deletion opencsp/app/target/target_color/target_color_bullseye.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ def bullseye_color_bar(
cx_offset_trim_pix,
target_img_width_pix,
):
# Bullseye.
"""
Placeholder
"""
for row in range(0, n_rows):
for col in range(0, n_cols):
r_mrad = bullseye_error.radius_in_mrad_given_row_col(
Expand Down
21 changes: 13 additions & 8 deletions opencsp/app/target/target_color/target_color_bullseye_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,26 @@ def meters_given_pixels(d_pixel, dpi):


def surface_normal_error_magnitude_given_radius_in_meters(r_meter, focal_length_meter):
# Computes the surface normal error of a reflection with a reflected image the given
# radius r_meter away from the target center.
#
# Correct if the mirror design is spherical, the view position is along the optical axis,
# and the target-to-mirror and camera-to-mirror distances are equal to the radius of curvature.
#
# Returns value in milliradians.
#
"""
Computes the surface normal error of a reflection with a reflected image the given
radius r_meter away from the target center.
Correct if the mirror design is spherical, the view position is along the optical axis,
and the target-to-mirror and camera-to-mirror distances are equal to the radius of curvature.
Returns value in milliradians.
"""

radius_of_curvature_meter = 2 * focal_length_meter
reflected_ray_angle = math.atan(r_meter / radius_of_curvature_meter) # radians
surface_normal_error = reflected_ray_angle / 2.0 # radians
return surface_normal_error * 1000.0 # Convert radians to milliradians.


def radius_in_mrad_given_row_col(n_rows, row, col, x_max, cx_offset_pix, y_offset_pix, focal_length_meter):
"""
Placeholder
"""
x = col
y = n_rows - row
cx = (x_max / 2) + cx_offset_pix
Expand Down
14 changes: 0 additions & 14 deletions opencsp/common/lib/camera/Camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,6 @@ class Camera:
def __init__(
self, intrinsic_mat: np.ndarray, distortion_coef: np.ndarray, image_shape_xy: tuple[int, int], name: str
):
"""
Calibrated machine vision camera representation.
Parameters
----------
intrinsic_mat : np.ndarray
distortion_coef : np.ndarray
1d array, distortion coefficients.
image_shape_xy : tuple(int)
(x, y), image size in pixels.
name : str
Name of camera/lens combination.
"""
if intrinsic_mat.shape[0] != 3 or intrinsic_mat.shape[1] != 3 or np.ndim(intrinsic_mat) != 2:
raise ValueError('Input intrinsic_mat must be a 3x3 ndarray.')

Expand Down
39 changes: 28 additions & 11 deletions opencsp/test/test_DocStringsExist.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from pathlib import Path
import inspect

# Assume opencsp is in PYHTONPATH
from opencsp.app.sofast.lib.ProcessSofastFringe import ProcessSofastFringe as Sofast
import opencsp as opencsp
import example as example

# TODO: why aren't these imported from import opencsp as opencsp above
from opencsp.app.camera_calibration.lib.ViewAnnotatedImages import ViewAnnotatedImages
from opencsp.app.sofast.SofastGUI import SofastGUI
from opencsp.app.sofast.lib import *
from opencsp.app.sofast.lib.visualize_setup import visualize_setup

# from opencsp.app.target.target_color.target_color_2d_gradient import target_color_2d_gradient
import opencsp.app.target.target_color.target_color_bullseye_error as target_color_bullseye_error
Expand Down Expand Up @@ -36,6 +38,8 @@ def test_docstrings_exist_for_methods():
opencsp.app.sofast.lib.DisplayShape.DisplayShape,
opencsp.app.sofast.lib.DistanceOpticScreen.DistanceOpticScreen,
opencsp.app.sofast.lib.DotLocationsFixedPattern.DotLocationsFixedPattern,
SofastGUI,
visualize_setup,
opencsp.app.sofast.lib.Fringes.Fringes,
opencsp.app.sofast.lib.ImageCalibrationAbstract.ImageCalibrationAbstract,
opencsp.app.sofast.lib.ImageCalibrationGlobal.ImageCalibrationGlobal,
Expand All @@ -55,15 +59,16 @@ def test_docstrings_exist_for_methods():
opencsp.app.sofast.lib.SystemSofastFringe.SystemSofastFringe,
SofastGUI,
]

target_class_list = [
target_color,
target_color_bullseye,
opencsp.app.target.target_color.lib.ImageColor,
target_color_bullseye_error,
target_color_bullseye,
target_color_one_color,
target_color_polar,
opencsp.app.target.target_color.lib.ImageColor,
target_color,
]
target_class_list = [target_color, target_color_polar, opencsp.app.target.target_color.lib.ImageColor]

camera_calibration_class_list = [
opencsp.app.camera_calibration.lib.calibration_camera,
opencsp.app.camera_calibration.lib.image_processing,
Expand All @@ -85,11 +90,23 @@ def test_docstrings_exist_for_methods():
class_list = sofast_class_list + target_class_list + camera_calibration_class_list + scene_reconstruction_class_list

for class_module in class_list:
method_list = [
func
for func in dir(class_module)
if callable(getattr(class_module, func)) and not func.startswith("__") and not func.startswith("_")
]
print(class_module)
method_list = []
if inspect.isclass(class_module):
method_list = [
func
for func in class_module.__dict__
if callable(getattr(class_module, func))
and not func.startswith("__")
and not func.startswith("_")
and not hasattr(super(class_module), func)
]
else:
method_list = [
func
for func in dir(class_module)
if callable(getattr(class_module, func)) and not func.startswith("__") and not func.startswith("_")
]

for method in method_list:
doc_exists = True
Expand Down

0 comments on commit 1f45058

Please sign in to comment.