Skip to content

Commit

Permalink
Unit tests upgrade. (#145)
Browse files Browse the repository at this point in the history
* Fix cluster validation.

* Fix logging.

* Refactor unit tests for creators.

* Add unit tests for message types.

* Bug fix.

* Global variables.

* Creator tests fix.
  • Loading branch information
kkeroo authored Dec 9, 2024
1 parent 88bc218 commit f11ad94
Show file tree
Hide file tree
Showing 23 changed files with 1,344 additions and 1,027 deletions.
2 changes: 1 addition & 1 deletion depthai_nodes/ml/messages/creators/clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def create_cluster_message(clusters: List[List[List[Union[float, int]]]]) -> Clu
if not isinstance(cluster, list):
raise TypeError(f"All clusters must be of type List, got {type(cluster)}")
for point in cluster:
if isinstance(point, list):
if not isinstance(point, list):
raise TypeError(
f"All points in clusters must be of type List, got {type(point)}"
)
Expand Down
1 change: 0 additions & 1 deletion depthai_nodes/ml/messages/creators/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def create_detection_message(
@raise ValueError: If the keypoints are not a numpy array of shape (N, M, 2 or 3).
@raise ValueError: If the masks are not a 3D numpy array of shape (img_height,
img_width, N) or (N, img_height, img_width).
@raise ValueError: If the masks are not in the range [0, 1].
@raise ValueError: If the keypoints scores are not a numpy array.
@raise ValueError: If the keypoints scores are not of shape [n_detections,
n_keypoints, 1].
Expand Down
8 changes: 4 additions & 4 deletions depthai_nodes/ml/parsers/utils/keypoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@ def transform_to_keypoints(
raise ValueError("Keypoints must be a numpy array.")
if len(keypoints.shape) != 2:
raise ValueError(
"Keypoints must be of shape (N, 2). Got shape {keypoints.shape}."
f"Keypoints must be of shape (N, 2). Got shape {keypoints.shape}."
)
if keypoints.shape[1] != 2 and keypoints.shape[1] != 3:
raise ValueError(
"Keypoints must be of shape (N, 2) or (N, 3). Got shape {keypoints.shape}."
f"Keypoints must be of shape (N, 2) or (N, 3). Got shape {keypoints.shape}."
)

if confidences is not None:
if not isinstance(confidences, np.ndarray):
raise ValueError("Confidences must be a numpy array.")
if len(confidences.shape) != 1:
raise ValueError(
"Confidences must be of shape (N,). Got shape {confidences.shape}."
f"Confidences must be of shape (N,). Got shape {confidences.shape}."
)
if len(confidences) != len(keypoints):
raise ValueError(
"Confidences should have same length as keypoints, got {len(confidences)} confidences and {len(keypoints)} keypoints."
f"Confidences should have same length as keypoints, got {len(confidences)} confidences and {len(keypoints)} keypoints."
)

dim = keypoints.shape[1]
Expand Down
155 changes: 0 additions & 155 deletions tests/unittests/test_creators/test_classification.py

This file was deleted.

Loading

0 comments on commit f11ad94

Please sign in to comment.