Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
- id: check-yaml
exclude: .gitlab-ci.yml
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.11
rev: v0.16.6
hooks:
- id: ruff-check
args:
Expand All @@ -23,7 +23,7 @@ repos:
- --target-version=py310
- --extend-select=UP,I
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.3.1
rev: 26.5.1
hooks:
- id: black
args:
Expand All @@ -43,7 +43,7 @@ repos:
additional_dependencies:
- tomli
- repo: https://github.com/jsh9/pydoclint
rev: 0.8.3
rev: 0.9.1
hooks:
- id: pydoclint
args:
Expand All @@ -52,7 +52,7 @@ repos:
- -athd=False
- -crt=False
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.48.0
rev: v0.49.1
hooks:
- id: markdownlint
args:
Expand All @@ -65,5 +65,5 @@ repos:
hooks:
- id: blackdoc
additional_dependencies:
- black==26.3.1
- black==26.5.1
- id: blackdoc-autoupdate-black
2 changes: 1 addition & 1 deletion docs/notebooks/1_demo_dataset.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1944,7 +1944,7 @@
"metadata": {},
"outputs": [],
"source": [
"new_label_map = {**COCO_pascal.label_map, **{1: \"something else\"}}\n",
"new_label_map = {**COCO_pascal.label_map, 1: \"something else\"}\n",
"COCO_incompatible = COCO_pascal.from_template(label_map=new_label_map)"
]
},
Expand Down
3 changes: 1 addition & 2 deletions lours/cli/caipy_to_fiftyone.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import socketserver
from argparse import ArgumentParser
from logging import warn
from pathlib import Path
from time import sleep
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -256,7 +255,7 @@
args = parser.parse_args()

if not args.launch_app and not args.persistent:
warn(
warning(

Check failure on line 258 in lours/cli/caipy_to_fiftyone.py

View workflow job for this annotation

GitHub Actions / run-pyright

"warning" is not defined (reportUndefinedVariable)
"App won't be launched and dataset is not persistent, this command will not"
" do anything",
RuntimeWarning,
Expand Down
8 changes: 4 additions & 4 deletions lours/dataset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@

__all__ = [
"Dataset",
"from_folder",
"from_files",
"from_caipy",
"from_caipy_generic",
"from_coco",
"from_coco_keypoints",
"from_crowd_human",
"from_darknet",
"from_darknet_yolov5",
"from_darknet_generic",
"from_darknet_json",
"from_crowd_human",
"from_darknet_yolov5",
"from_files",
"from_folder",
"from_mot",
"from_parquet",
"from_pascalVOC_detection",
Expand Down
14 changes: 7 additions & 7 deletions lours/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Dataset:
for a complete explanation of main principles.
- :ref:`Dataset demo notebook </notebooks/1_demo_dataset.ipynb>`

""" # noqa: E501
"""

dataset_name: str | None
images_root: Path
Expand Down Expand Up @@ -3535,12 +3535,12 @@ class mapping. Otherwise, keep them as is (with potential class fusion).
Index: []
Label map :
{1: 'interview'}
""" # noqa: E501
"""
if not remove_not_mapped:
not_mapped = {
category_id: category_id
for category_id in self.label_map.keys()
if category_id not in class_mapping.keys()
if category_id not in class_mapping
}
class_mapping = {**class_mapping, **not_mapped}
new_label_map = {
Expand Down Expand Up @@ -3726,7 +3726,7 @@ class mapping. Otherwise, keep them as is (with potential class fusion).
[2 rows x 8 columns]
Label map :
{0: 'new_listen', 1: 'new_reach'}
""" # noqa: E501
"""
if df.index.name == "input_category_id":
mapping_df = df
else:
Expand Down Expand Up @@ -3785,7 +3785,7 @@ class mapping. Otherwise, keep them as is (with potential class fusion).
- :meth:`.remap_from_other`
- :meth:`.remove_classes`
- :meth:`.keep_classes`
""" # noqa: E501
"""
mapping_df = pd.read_csv(csv).set_index("input_category_id")
return self.remap_from_dataframe(
mapping_df, remove_not_mapped, remove_emptied_images
Expand Down Expand Up @@ -4965,7 +4965,7 @@ def to_caipy(
See Also:
- :mod:`lours.dataset.io.caipy`
- :meth:`to_caipy_generic`
""" # noqa: E501
"""
from .io.caipy import dataset_to_caipy

return dataset_to_caipy(
Expand Down Expand Up @@ -5033,7 +5033,7 @@ def to_caipy_generic(
- :mod:`lours.dataset.io.caipy`
- :meth:`to_caipy`

""" # noqa: E501
"""
from .io.caipy import dataset_to_caipy_generic

return dataset_to_caipy_generic(
Expand Down
4 changes: 2 additions & 2 deletions lours/dataset/io/caipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def from_caipy(
- :ref:`Tutorial on schemas </notebooks/6_demo_schemas.ipynb>`
- :ref:`Tutorial on booleanization </notebooks/7_demo_booleanize.ipynb>`
- `cAIpy specifications <UPDATE-ME>`_
""" # noqa: E501
"""
dataset_path = Path(dataset_path)
annotations_folder = dataset_path / "Annotations"
images_folder = dataset_path / "Images"
Expand Down Expand Up @@ -285,7 +285,7 @@ def from_caipy_generic(
- :ref:`Tutorial on schemas </notebooks/6_demo_schemas.ipynb>`
- :ref:`Tutorial on booleanization </notebooks/7_demo_booleanize.ipynb>`
- `cAIpy specifications <UPDATE-ME>`_
""" # noqa: E501
"""
if use_schema and json_schema is not None:
if isinstance(json_schema, dict):
schema = json_schema
Expand Down
5 changes: 2 additions & 3 deletions lours/dataset/io/darknet.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ def write_data_file(data: dict[str, str | int], data_file: Path) -> None:
"""
keys = ["classes", "train", "valid", "names", "backup"]
with open(data_file, "w") as f:
for key in keys:
f.write(f"{key} = {data.get(key, '')}\n")
f.writelines(f"{key} = {data.get(key, '')}\n" for key in keys)


def yolov5_img_path_to_label_path(img_path: Path) -> Path:
Expand All @@ -129,7 +128,7 @@ def yolov5_img_path_to_label_path(img_path: Path) -> Path:

Returns:
corresponding label file as it would have been searched for by yolov5
""" # noqa: E501
"""
annotation_path = img_path.with_suffix(".txt")
folder_parts = list(annotation_path.parts)
if "images" in folder_parts:
Expand Down
4 changes: 2 additions & 2 deletions lours/dataset/io/schema_util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
)

__all__ = [
"fill_with_dtypes_and_default_value",
"flatten_schema",
"get_dtypes_and_default_values",
"get_enums",
"get_remapping_dict_from_names",
"get_remapping_dict_from_schema",
"flatten_schema",
"load_json_schema",
"fill_with_dtypes_and_default_value",
"remap_dict",
]
1 change: 0 additions & 1 deletion lours/dataset/io/schema_util/schema_util_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,5 @@ def remap_dict(flattened_dict: dict, mapping_tree: dict | None = None) -> dict:
# is clearly not na
if isna.any(): # pyright: ignore
raise ValueError(f"value contains nan : {output_value}")
pass
output_dict[k] = output_value
return output_dict
2 changes: 1 addition & 1 deletion lours/dataset/remap_presets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import pandas as pd

__all__ = ["presets", "list_available_presets"]
__all__ = ["list_available_presets", "presets"]

presets = {}
presets_folder = files("lours") / "dataset" / "remap_presets"
Expand Down
1 change: 0 additions & 1 deletion lours/dataset/split/balanced_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ def check_groups(
"category and continuous group must be a "
"perfect partition of the histogram index"
)
return


def hist_distance(
Expand Down
2 changes: 1 addition & 1 deletion lours/evaluation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .detection import CrowdDetectionEvaluator, DetectionEvaluator
from .evaluator import Evaluator

__all__ = ["Evaluator", "DetectionEvaluator", "CrowdDetectionEvaluator"]
__all__ = ["CrowdDetectionEvaluator", "DetectionEvaluator", "Evaluator"]
2 changes: 1 addition & 1 deletion lours/evaluation/detection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from .crowd_detection_evaluator import CrowdDetectionEvaluator
from .detection_evaluator import DetectionEvaluator

__all__ = ["DetectionEvaluator", "CrowdDetectionEvaluator", "util"]
__all__ = ["CrowdDetectionEvaluator", "DetectionEvaluator", "util"]
4 changes: 0 additions & 4 deletions lours/evaluation/detection/crowd_detection_evaluator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from collections.abc import Iterable
from functools import partial
from typing import TYPE_CHECKING

import numpy as np
import pandas as pd
Expand All @@ -15,9 +14,6 @@
from .detection_evaluator_base import DetectionEvaluatorBase
from .util import resample_count

if TYPE_CHECKING:
pass


class CrowdDetectionEvaluator(DetectionEvaluatorBase):
"""Class specialization for crowd detection and counting tasks.
Expand Down
4 changes: 0 additions & 4 deletions lours/evaluation/detection/detection_evaluator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from collections.abc import Iterable
from functools import partial
from typing import TYPE_CHECKING

import numpy as np
import pandas as pd
Expand All @@ -17,9 +16,6 @@
pr_curve,
)

if TYPE_CHECKING:
pass


class DetectionEvaluator(DetectionEvaluatorBase):
"""Class specialization for detection tasks Note that the constructor is the
Expand Down
4 changes: 1 addition & 3 deletions lours/utils/doc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ def construct_attribute_column(
int
| Sequence[str]
| Sequence[int | Sequence[float] | Sequence[str] | dict[str, float]]
| dict[
str, int | Sequence[float] | Sequence[str] | Sequence[float] | dict[str, float]
]
| dict[str, int | Sequence[float] | Sequence[str] | dict[str, float]]
)
"""The random attribute columns type is a way to design a column with random
attributes.
Expand Down
2 changes: 0 additions & 2 deletions lours/utils/label_map_merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ class IncompatibleLabelMapsError(ValueError):
from other ValueError exceptions
"""

pass


def merge_label_maps(
left: dict[int, str], right: dict[int, str], method: str = "inner"
Expand Down
11 changes: 4 additions & 7 deletions test_lours/test_dataset/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,10 @@ def test_caipy_io():
assert max(map(len, subfolders)) == 0

# Save to caipy generic and reload, ensure they are the same
with TemporaryDirectory() as t_images:
with TemporaryDirectory() as t_annotations:
dataset.to_caipy_generic(
t_images, t_annotations, copy_images=True, to_jpg=True
)
dataset2 = from_caipy_generic(t_images, t_annotations)
assert_dataset_equal(dataset, dataset2)
with TemporaryDirectory() as t_images, TemporaryDirectory() as t_annotations:
dataset.to_caipy_generic(t_images, t_annotations, copy_images=True, to_jpg=True)
dataset2 = from_caipy_generic(t_images, t_annotations)
assert_dataset_equal(dataset, dataset2)

# Save to coco and reload, ensure they are the same
with TemporaryDirectory() as t:
Expand Down
2 changes: 0 additions & 2 deletions test_lours/test_dataset/test_split/test_balanced_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def test_dataset_share1():
assert same_share_cost == 0
share_cost = balanced_groups.dataset_share_distance(test_share1, test_share2)
assert share_cost == 1
return


def test_dataset_share2():
Expand All @@ -71,7 +70,6 @@ def test_dataset_share2():
share_cost = balanced_groups.dataset_share_distance(test_share1, test_share2)
print(share_cost)
assert share_cost == 5 / 7
return


def test_check_group():
Expand Down
Loading