Skip to content

Commit

Permalink
Conform to pydocstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
roomrys committed Nov 20, 2024
1 parent de1728e commit 553964e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 21 deletions.
10 changes: 0 additions & 10 deletions sleap_io/model/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def _validate_shape(self, attribute: attrs.Attribute, value):
Raises:
ValueError: If attribute shape is not as expected.
"""

# Define metadata for each attribute
attr_metadata = {
"matrix": {"shape": (3, 3), "type": np.ndarray},
Expand Down Expand Up @@ -87,7 +86,6 @@ def _validate_shape(self, attribute: attrs.Attribute, value):

def __attrs_post_init__(self):
"""Initialize extrinsic matrix from rotation and translation vectors."""

# Initialize extrinsic matrix
self._extrinsic_matrix = np.eye(4, dtype="float64")
self._extrinsic_matrix[:3, :3] = cv2.Rodrigues(self._rvec)[0]
Expand All @@ -100,7 +98,6 @@ def rvec(self) -> np.ndarray:
Returns:
Rotation vector of camera of size 3.
"""

return self._rvec

@rvec.setter
Expand All @@ -123,7 +120,6 @@ def tvec(self) -> np.ndarray:
Returns:
Translation vector of camera of size 3.
"""

return self._tvec

@tvec.setter
Expand All @@ -133,7 +129,6 @@ def tvec(self, value: np.ndarray):
Args:
value: Translation vector of size 3.
"""

self._tvec = value

# Update extrinsic matrix
Expand All @@ -146,7 +141,6 @@ def extrinsic_matrix(self) -> np.ndarray:
Returns:
Extrinsic matrix of camera of size 4 x 4.
"""

return self._extrinsic_matrix

@extrinsic_matrix.setter
Expand All @@ -156,7 +150,6 @@ def extrinsic_matrix(self, value: np.ndarray):
Args:
value: Extrinsic matrix of size 4 x 4.
"""

self._extrinsic_matrix = value

# Update rotation and translation vectors
Expand All @@ -172,7 +165,6 @@ def undistort_points(self, points: np.ndarray) -> np.ndarray:
Returns:
Undistorted points of shape (N, 2).
"""

shape = points.shape
points = points.reshape(-1, 1, 2)
out = cv2.undistortPoints(points, self.matrix, self.dist)
Expand All @@ -187,7 +179,6 @@ def project(self, points: np.ndarray) -> np.ndarray:
Returns:
Projected 2D points of shape (N, 1, 2).
"""

points = points.reshape(-1, 1, 3)
out, _ = cv2.projectPoints(
points,
Expand All @@ -211,7 +202,6 @@ def __getattr__(self, name: str):
Raises:
AttributeError: If attribute does not exist.
"""

if name in self.__attrs_attrs__:
return getattr(self, name)

Check warning on line 206 in sleap_io/model/camera.py

View check run for this annotation

Codecov / codecov/patch

sleap_io/model/camera.py#L206

Added line #L206 was not covered by tests

Expand Down
11 changes: 0 additions & 11 deletions tests/model/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

def test_camera_name():
"""Test camera name converter always converts to string."""

# During initialization
camera = Camera(name=12)
assert camera.name == "12"
Expand All @@ -25,7 +24,6 @@ def test_camera_name():

def test_camera_matrix():
"""Test camera matrix converter and validator."""

matrix_list = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
matrix_array = np.array(matrix_list)

Expand All @@ -48,7 +46,6 @@ def test_camera_matrix():

def test_camera_distortions():
"""Test camera distortion converter and validator."""

distortions_unraveled = [[1], [2], [3], [4], [5]]
distortions_raveled = np.array(distortions_unraveled).ravel()

Expand All @@ -68,7 +65,6 @@ def test_camera_distortions():

def test_camera_size():
"""Test camera size converter and validator."""

size = (100, 200)

# During initialization
Expand Down Expand Up @@ -96,7 +92,6 @@ def construct_extrinsic_matrix(rvec, tvec):
Returns:
Extrinsic matrix of camera of size (4, 4) and type float64.
"""

extrinsic_matrix = np.eye(4)
extrinsic_matrix[:3, :3] = cv2.Rodrigues(np.array(rvec))[0]
extrinsic_matrix[:3, 3] = tvec
Expand All @@ -106,7 +101,6 @@ def construct_extrinsic_matrix(rvec, tvec):

def test_camera_rvec():
"""Test camera rotation vector converter and validator."""

rvec = [1, 2, 3]

# During initialization
Expand Down Expand Up @@ -138,7 +132,6 @@ def test_camera_rvec():

def test_camera_tvec():
"""Test camera translation vector converter and validator."""

tvec = [1, 2, 3]

# During initialization
Expand Down Expand Up @@ -167,7 +160,6 @@ def test_camera_tvec():

def test_camera_extrinsic_matrix():
"""Test camera extrinsic matrix method."""

# During initialization

# ... with rvec and tvec
Expand Down Expand Up @@ -207,7 +199,6 @@ def test_camera_extrinsic_matrix():
# TODO: Remove when implement triangulation without aniposelib
def test_camera_aliases():
"""Test camera aliases for attributes."""

camera = Camera(
matrix=[[1, 2, 3], [4, 5, 6], [7, 8, 9]],
dist=[[1], [2], [3], [4], [5]],
Expand All @@ -226,7 +217,6 @@ def test_camera_aliases():

def test_camera_undistort_points():
"""Test camera undistort points method."""

camera = Camera(
matrix=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
dist=[[0], [0], [0], [0], [0]],
Expand All @@ -246,7 +236,6 @@ def test_camera_undistort_points():

def test_camera_project():
"""Test camera project method."""

camera = Camera(
matrix=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
dist=[[0], [0], [0], [0], [0]],
Expand Down

0 comments on commit 553964e

Please sign in to comment.