54 lines
1.1 KiB
Python
54 lines
1.1 KiB
Python
|
|
# -*- coding: utf-8 -*-
|
||
|
|
|
||
|
|
from datetime import datetime
|
||
|
|
from pathlib import Path
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
from . import check_bad_imports
|
||
|
|
from mmp.a4 import anchor_grid, label_grid, dataset
|
||
|
|
|
||
|
|
current_assignment = pytest.mark.skipif(
|
||
|
|
not (datetime(2025, 11, 6) <= datetime.now() <= datetime(2025, 11, 12, 23, 59, 59)),
|
||
|
|
reason="This is not the current assignment.",
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
@current_assignment
|
||
|
|
def test_no_abs_import():
|
||
|
|
paths = list(Path().glob("mmp/a4/*.py"))
|
||
|
|
check_bad_imports(paths)
|
||
|
|
|
||
|
|
|
||
|
|
@current_assignment
|
||
|
|
def test_anchor_grid():
|
||
|
|
grid = anchor_grid.get_anchor_grid(
|
||
|
|
num_rows=4,
|
||
|
|
num_cols=5,
|
||
|
|
scale_factor=12.0,
|
||
|
|
anchor_widths=[30.0, 80.0],
|
||
|
|
aspect_ratios=[0.5, 1.0],
|
||
|
|
)
|
||
|
|
assert grid.ndim == 5
|
||
|
|
assert grid.shape[-1] == 4
|
||
|
|
|
||
|
|
|
||
|
|
@current_assignment
|
||
|
|
def test_iou():
|
||
|
|
label_grid.iou
|
||
|
|
|
||
|
|
|
||
|
|
@current_assignment
|
||
|
|
def test_label_grid():
|
||
|
|
lg, *_ = label_grid.get_label_grid(
|
||
|
|
anchor_grid=anchor_grid.get_anchor_grid(2, 2, 10, [10.0], [1.0]),
|
||
|
|
gts=[],
|
||
|
|
min_iou=0.5,
|
||
|
|
)
|
||
|
|
assert lg.dtype == bool
|
||
|
|
|
||
|
|
|
||
|
|
@current_assignment
|
||
|
|
def test_dataset():
|
||
|
|
dataset.MMP_Dataset
|
||
|
|
dataset.calculate_max_coverage
|