Skip to content

Commit a96dc46

Browse files
Prepare release (#33)
* Release preparation. - README updated. - polygon is excluded from the codebase. * Test utils separated. * load_json moved to tests/utils.
1 parent bcd2b18 commit a96dc46

File tree

6 files changed

+71
-78
lines changed

6 files changed

+71
-78
lines changed

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ Light weight toolkit for bounding boxes providing conversion between bounding bo
3030
- **w:** width
3131
- **c:** center
3232

33+
34+
## News 🔥
35+
36+
* 2024/10/07 - [Annotations](#annotation-file-conversion) are supported for YOLO, COCO and VOC formats.
37+
38+
## Roadmap 🛣️
39+
40+
- [X] Annotation file support.
41+
- [ ] (Upcoming) 3D Bounding Box support.
42+
- [ ] (Upcoming) Polygon support.
43+
3344
### Important Notice
3445
Support for Python<3.8 will be dropped starting version `0.2` though the development for Python3.6 and Python3.7 may
3546
continue where it will be developed under version `0.1.x` for future versions. This may introduce; however, certain
@@ -287,17 +298,17 @@ pip install -e .[dev]
287298

288299
To tests simply run.
289300

290-
python tests/run_tests.py
301+
python -m tests.run_tests
291302

292303
### Code Style
293304

294305
To check code style,
295306

296-
python tests/run_code_style.py check
307+
python -m tests.run_code_style check
297308

298309
To format codebase,
299310

300-
python tests/run_code_style.py format
311+
python -m tests.run_code_style format
301312

302313
## License
303314

pybboxes/types/polygon.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/run_code_style.py renamed to scripts/run_code_style.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22

3-
from tests.utils import shell, validate_and_exit
3+
from scripts.utils import shell, validate_and_exit
44

55
if __name__ == "__main__":
66
arg = sys.argv[1]

tests/run_tests.py renamed to scripts/run_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from tests.utils import shell, validate_and_exit
1+
from scripts.utils import shell, validate_and_exit
22

33
if __name__ == "__main__":
44
sts_tests = shell("pytest --cov pybboxes --cov-report term-missing --cov-report xml")

scripts/utils.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import json
2+
import os
3+
import re
4+
import shutil
5+
import sys
6+
7+
8+
def shell(command, exit_status=0):
9+
"""
10+
Run command through shell and return exit status if exit status of command run match with given exit status.
11+
12+
Args:
13+
command: (str) Command string which runs through system shell.
14+
exit_status: (int) Expected exit status of given command run.
15+
16+
Returns: actual_exit_status
17+
18+
"""
19+
actual_exit_status = os.system(command)
20+
if actual_exit_status == exit_status:
21+
return 0
22+
return actual_exit_status
23+
24+
25+
def validate_and_exit(expected_out_status=0, **kwargs):
26+
if all([arg == expected_out_status for arg in kwargs.values()]):
27+
# Expected status, OK
28+
sys.exit(0)
29+
else:
30+
# Failure
31+
print_console_centered("Summary Results")
32+
fail_count = 0
33+
for component, exit_status in kwargs.items():
34+
if exit_status != expected_out_status:
35+
print(f"{component} failed.")
36+
fail_count += 1
37+
print_console_centered(f"{len(kwargs)-fail_count} success, {fail_count} failure")
38+
sys.exit(1)
39+
40+
41+
def print_console_centered(text: str, fill_char="="):
42+
w, _ = shutil.get_terminal_size((80, 20))
43+
print(f" {text} ".center(w, fill_char))
44+
45+
46+
def shell_capture(command, out_json=True):
47+
out = os.popen(command).read()
48+
if out_json:
49+
out = re.findall(r"{\s+.*\}", out, flags=re.MULTILINE | re.DOTALL)[0].replace("\n", "")
50+
return json.loads(out)
51+
return out

tests/utils.py

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,16 @@
11
import json
2-
import os
3-
import re
4-
import shutil
5-
import sys
6-
from typing import Dict
72

83
from deepdiff import DeepDiff
94

105

11-
def load_json(path: str):
12-
with open(path, "r") as jf:
13-
content = json.load(jf)
14-
return content
15-
16-
17-
def shell(command, exit_status=0):
18-
"""
19-
Run command through shell and return exit status if exit status of command run match with given exit status.
20-
21-
Args:
22-
command: (str) Command string which runs through system shell.
23-
exit_status: (int) Expected exit status of given command run.
24-
25-
Returns: actual_exit_status
26-
27-
"""
28-
actual_exit_status = os.system(command)
29-
if actual_exit_status == exit_status:
30-
return 0
31-
return actual_exit_status
32-
33-
34-
def validate_and_exit(expected_out_status=0, **kwargs):
35-
if all([arg == expected_out_status for arg in kwargs.values()]):
36-
# Expected status, OK
37-
sys.exit(0)
38-
else:
39-
# Failure
40-
print_console_centered("Summary Results")
41-
fail_count = 0
42-
for component, exit_status in kwargs.items():
43-
if exit_status != expected_out_status:
44-
print(f"{component} failed.")
45-
fail_count += 1
46-
print_console_centered(f"{len(kwargs)-fail_count} success, {fail_count} failure")
47-
sys.exit(1)
48-
49-
50-
def print_console_centered(text: str, fill_char="="):
51-
w, _ = shutil.get_terminal_size((80, 20))
52-
print(f" {text} ".center(w, fill_char))
53-
54-
556
def assert_almost_equal(actual, desired, decimal=3, exclude_paths=None, **kwargs):
567
# significant digits default value changed to 3 (from 5) due to variety in
578
# results for different hardware architectures.
589
diff = DeepDiff(actual, desired, significant_digits=decimal, exclude_paths=exclude_paths, **kwargs)
5910
assert diff == {}, f"Actual and Desired Dicts are not Almost Equal:\n {json.dumps(diff, indent=2, default=str)}"
6011

6112

62-
def shell_capture(command, out_json=True):
63-
out = os.popen(command).read()
64-
if out_json:
65-
out = re.findall(r"{\s+.*\}", out, flags=re.MULTILINE | re.DOTALL)[0].replace("\n", "")
66-
return json.loads(out)
67-
return out
13+
def load_json(path: str):
14+
with open(path, "r") as jf:
15+
content = json.load(jf)
16+
return content

0 commit comments

Comments
 (0)