Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
867de4c
Add mdformat hook and update docs scan/exclude
C-Achard Jun 1, 2026
0937706
Use NumPy docstring style and widen line length
C-Achard Jun 1, 2026
1a8d3cf
Format all docstrings
C-Achard Jun 1, 2026
c99aa9d
Format all docs
C-Achard Jun 1, 2026
6125126
Add dev-docs to mdformat
C-Achard Jun 1, 2026
4f32679
Disable mdformat pre-commit hook (broken)
C-Achard Jun 1, 2026
84466b0
Revert "Format all docs"
C-Achard Jun 1, 2026
794619b
use google-style docstrings + remove numpydoc
deruyter92 Jun 2, 2026
640deb2
apply ruff safe fixes all docstrings
deruyter92 Jun 2, 2026
2078850
docs: convert docstrings to Google style (batch A1)
deruyter92 Jun 3, 2026
d59328d
docs: convert docstrings to Google style (batch A2)
deruyter92 Jun 3, 2026
00425f4
docs: convert docstrings to Google style (batch A3)
deruyter92 Jun 3, 2026
0998f8e
docs: convert docstrings to Google style (batch A4)
deruyter92 Jun 3, 2026
944a561
docs: convert docstrings to Google style (batch A5)
deruyter92 Jun 3, 2026
1e33ab0
docs: convert docstrings to Google style (batch B1)
deruyter92 Jun 3, 2026
aede4c4
docs: convert docstrings to Google style (batch B2)
deruyter92 Jun 3, 2026
fd68cb0
docs: convert docstrings to Google style (batch B3)
deruyter92 Jun 3, 2026
741eb42
docs: convert docstrings to Google style (batch B4)
deruyter92 Jun 3, 2026
c046c73
docs: convert docstrings to Google style (batch B5)
deruyter92 Jun 3, 2026
1a50d1c
docs: convert docstrings to Google style (batch B6)
deruyter92 Jun 3, 2026
75046ae
docs: fix existing malformed Google style docstrings (batch C)
deruyter92 Jun 3, 2026
e589365
docs: fix existing outdated Google style docstrings (batch D)
deruyter92 Jun 3, 2026
2580c8b
doc: google docstyle fixes (audit)
deruyter92 Jun 3, 2026
c6d0a46
docs: fix examples in docstrings
deruyter92 Jun 4, 2026
dd04239
Docs: fix cli Args (was Options)
deruyter92 Jun 4, 2026
47a7485
docs: fix docstring exceptions (Raises) prose -> structured
deruyter92 Jun 4, 2026
30a2e36
docs: fix missing function descriptions in docstrings
deruyter92 Jun 4, 2026
4cbef89
docs: fix DLCLoader to_coco docstring
deruyter92 Jun 4, 2026
c949ffc
docs: manually fix incorrect args in docstrings (using griffe)
deruyter92 Jun 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,27 @@ repos:
args: [--check, --diff]
stages: [manual]

- repo: https://github.com/hukkin/mdformat
rev: 1.0.0
hooks:
- id: mdformat
additional_dependencies:
- mdformat-myst
files: ^docs/.*\.md$
stages: [pre-commit]

# - repo: https://github.com/hukkin/mdformat
# Broken currently, replaces all autorefs with broken escaped links.
# See https://github.com/KyleKing/mdformat-mkdocs/issues/80
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep an eye on this issue.

# rev: 1.0.0
# hooks:
# - id: mdformat
# additional_dependencies:
# - mdformat-mkdocs==5.2.0b2
# files: ^dev-docs/.*\.md$
# stages: [pre-commit]


# check only, no modifications
- repo: local
hooks:
Expand All @@ -91,6 +112,7 @@ repos:
language: python
pass_filenames: true
files: ^(docs/|examples/(JUPYTER|COLAB)/|tools/).*(\.md|\.ipynb)$
exclude: ^tools/docs_audits/
args:
- --config
- tools/docs_and_notebooks_report_config.yml
Expand Down
4 changes: 3 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ sphinx:
- "venv/**"
- "**/site-packages/**"
- "**/_build/**"
napoleon_google_docstring: true
napoleon_numpy_docstring: false
extra_extensions:
- numpydoc
- sphinx.ext.napoleon
- sphinxcontrib.mermaid

execute:
Expand Down
1 change: 0 additions & 1 deletion deeplabcut/benchmark/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def compute_pose_map(self, results_objects):

def evaluate(self, name: str, on_error="raise"):
"""Evaluate this benchmark with all registered methods."""

if name not in self.names():
raise ValueError(f"{name} is not registered. Valid names are {self.names()}")
if on_error not in ("ignore", "return", "raise"):
Expand Down
7 changes: 4 additions & 3 deletions deeplabcut/benchmark/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def calc_prediction_errors(preds, gt):

def _map(strings, substrings):
"""Map image paths from predicted data to GT as the first are typically absolute
whereas the latter are relative to the project path."""

whereas the latter are relative to the project path.
"""
lookup = dict()
strings_ = strings.copy()
substrings_ = substrings.copy()
Expand Down Expand Up @@ -241,7 +241,8 @@ def calc_rmse_from_obj(

def load_test_images(h5file: str, metadata: str) -> list[str]:
"""Returns the names of the test images for the benchmark, in the order
corresponding to the test indices."""
corresponding to the test indices.
"""
df = pd.read_hdf(h5file)
test_indices = _load_test_indices(metadata)
df_test = df.iloc[test_indices]
Expand Down
117 changes: 49 additions & 68 deletions deeplabcut/benchmark/mot.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,17 @@ def convert_bboxes_to_xywh(bboxes: NDArray, inplace: bool = False) -> NDArray:
"""Converts bounding box coordinates from [x_min, y_min, x_max, y_max] format to [x,
y, width, height] format.

Parameters
----------
bbox : numpy.ndarray
A 2D array of shape (N, M), where N is the number of bounding boxes
and M >= 4. The first four columns represent the bounding box in the format
[x_min, y_min, x_max, y_max].
inplace : bool, optional
If True, modifies the input array in place. If False, returns a copy of
the array with the converted bounding box format. Defaults to False.

Returns
-------
numpy.ndarray or None
If `inplace` is False, returns a new array of the same shape as `bbox`
with the format [x, y, width, height]. If `inplace` is True, the input
array is modified directly, and nothing is returned.
Args:
bboxes (numpy.ndarray): A 2D array of shape (N, M), where N is the number of bounding boxes
and M >= 4. The first four columns represent the bounding box in the format
[x_min, y_min, x_max, y_max].
inplace (bool, optional): If True, modifies the input array in place. If False, returns a copy of
the array with the converted bounding box format. Defaults to False.

Returns:
numpy.ndarray or None: If `inplace` is False, returns a new array of the same shape as `bboxes`
with the format [x, y, width, height]. If `inplace` is True, the input
array is modified directly, and nothing is returned.
"""
w = bboxes[:, 2] - bboxes[:, 0]
h = bboxes[:, 3] - bboxes[:, 1]
Expand All @@ -59,31 +54,24 @@ def convert_bboxes_to_xywh(bboxes: NDArray, inplace: bool = False) -> NDArray:
def reconstruct_bboxes_from_bodyparts(data: pd.DataFrame, margin: float, to_xywh: bool = False) -> NDArray:
"""Reconstructs bounding boxes from body part coordinates and likelihoods.

Parameters
----------
data : pandas.DataFrame
A DataFrame containing body part data with a multi-level column index.
The expected levels include 'x', 'y', and 'likelihood', where:
- 'x' and 'y' contain the coordinates of the body parts.
- 'likelihood' contains the confidence scores for each body part.
margin : float
The margin to add/subtract from the minimum/maximum coordinates when defining the bounding box.
to_xywh : bool, optional
If True, converts the bounding box format from [x_min, y_min, x_max, y_max]
to [x, y, width, height]. Defaults to False.

Returns
-------
numpy.ndarray
An array of shape (N, 5), where N is the number of rows in `data`.
Each row represents a bounding box with the following values:
- [x_min, y_min, x_max, y_max, likelihood]
If `to_xywh` is True, the format will be [x, y, width, height, likelihood].

Notes
-----
- NaN values in the input data are ignored when computing the bounding box dimensions.
- Warnings related to NaN values are suppressed during calculations.
Args:
data (pandas.DataFrame): A DataFrame containing body part data with a multi-level column index.
The expected levels include 'x', 'y', and 'likelihood', where:
- 'x' and 'y' contain the coordinates of the body parts.
- 'likelihood' contains the confidence scores for each body part.
margin (float): The margin to add/subtract from the minimum/maximum coordinates when defining the bounding box.
to_xywh (bool, optional): If True, converts the bounding box format from [x_min, y_min, x_max, y_max]
to [x, y, width, height]. Defaults to False.

Returns:
numpy.ndarray: An array of shape (N, 5), where N is the number of rows in `data`.
Each row represents a bounding box with the following values:
- [x_min, y_min, x_max, y_max, likelihood]
If `to_xywh` is True, the format will be [x, y, width, height, likelihood].

Note:
- NaN values in the input data are ignored when computing the bounding box dimensions.
- Warnings related to NaN values are suppressed during calculations.
"""
x = data.xs("x", axis=1, level="coords")
y = data.xs("y", axis=1, level="coords")
Expand All @@ -103,33 +91,26 @@ def reconstruct_bboxes_from_bodyparts(data: pd.DataFrame, margin: float, to_xywh
def reconstruct_all_bboxes(data: pd.DataFrame, margin: float, to_xywh: bool = False) -> NDArray:
"""Reconstructs bounding boxes for multiple individuals from body part data.

Parameters
----------
data : pandas.DataFrame
A DataFrame containing body part data with a multi-level column index.
The expected levels include:
- 'individuals': Names of the individuals (e.g., animals).
- 'x', 'y', and 'likelihood': Coordinate and confidence data for body parts.
margin : float
The margin to add/subtract from the minimum/maximum coordinates when defining the bounding box.
to_xywh : bool
If True, converts the bounding box format from [x_min, y_min, x_max, y_max]
to [x, y, width, height].

Returns
-------
numpy.ndarray
A 3D array of shape (A, F, 5), where:
- A is the number of individuals (excluding 'single', if present).
- F is the number of frames (rows) in the input `data`.
- Each bounding box is represented as [x_min, y_min, x_max, y_max, likelihood].
If `to_xywh` is True, the format will be [x, y, width, height, likelihood].

Notes
-----
- Individuals are extracted from the 'individuals' level of the DataFrame columns.
- If an individual named 'single' exists, it is excluded from the bounding box computation.
- NaN values in the input data are ignored during calculations.
Args:
data (pandas.DataFrame): A DataFrame containing body part data with a multi-level column index.
The expected levels include:
- 'individuals': Names of the individuals (e.g., animals).
- 'x', 'y', and 'likelihood': Coordinate and confidence data for body parts.
margin (float): The margin to add/subtract from the minimum/maximum coordinates when defining the bounding box.
to_xywh (bool, optional): If True, converts the bounding box format from [x_min, y_min, x_max, y_max]
to [x, y, width, height]. Defaults to False.

Returns:
numpy.ndarray: A 3D array of shape (A, F, 5), where:
- A is the number of individuals (excluding 'single', if present).
- F is the number of frames (rows) in the input `data`.
- Each bounding box is represented as [x_min, y_min, x_max, y_max, likelihood].
If `to_xywh` is True, the format will be [x, y, width, height, likelihood].

Note:
- Individuals are extracted from the 'individuals' level of the DataFrame columns.
- If an individual named 'single' exists, it is excluded from the bounding box computation.
- NaN values in the input data are ignored during calculations.
"""
animals = data.columns.get_level_values("individuals").unique().tolist()
try:
Expand Down
Loading