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
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v5.0.0"
rev: "v6.0.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -16,7 +16,7 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
rev: v2.4.1
hooks:
- id: codespell
args:
Expand All @@ -25,17 +25,17 @@ repos:
]
exclude: "BIBLIOGRAPHY.bib|CONTRIBUTORS.rst|.*\\.ipynb|./colour_cxf/cxf3/.*|CxF3_Core.xsd"
- repo: https://github.com/PyCQA/isort
rev: "5.13.2"
rev: "7.0.0"
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.8.2"
rev: "v0.14.14"
hooks:
- id: ruff-format
- id: ruff
args: [--fix]
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.19.1
rev: 1.20.0
hooks:
- id: blacken-docs
language_version: python3.10
Expand Down
4 changes: 2 additions & 2 deletions examples/combining_color_representations.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
spectrum = color_value
print(
f"""First few spectral values: {
' '.join(map(str, spectrum.value[:5]))
" ".join(map(str, spectrum.value[:5]))
}..."""
)

Expand All @@ -124,6 +124,6 @@

print(
f"""Available color representations for {obj.name}: {
', '.join(representations)
", ".join(representations)
}"""
)
4 changes: 2 additions & 2 deletions examples/working_with_spectral_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
print(f"Number of spectral values: {len(spectrum.value)}")
print(
f"""First few spectral values: {
' '.join(map(str,spectrum.value[:5]))
" ".join(map(str, spectrum.value[:5]))
}..."""
)

Expand Down Expand Up @@ -135,6 +135,6 @@
print(f"Number of spectral values: {len(spectrum.value)}")
print(
f"""First few spectral values: {
' '.join(map(str,spectrum.value[:5]))
" ".join(map(str, spectrum.value[:5]))
}..."""
)
6 changes: 3 additions & 3 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ def inner(text: str) -> str:
"""Format and pads inner text for the message box."""

return (
f'*{" " * padding}'
f'{text}{" " * (width - len(text) - padding * 2 - 2)}'
f'{" " * padding}*'
f"*{' ' * padding}"
f"{text}{' ' * (width - len(text) - padding * 2 - 2)}"
f"{' ' * padding}*"
)

print_callable("=" * width)
Expand Down
14 changes: 7 additions & 7 deletions utilities/benchmark_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def generate_large_cxf_file(num_samples: int) -> bytes:
xml_bytes = xml_content.encode("utf-8")

print(
f"Generated CxF file: {len(xml_bytes):,} bytes ({len(xml_bytes)/1024/1024:.1f} MB)"
f"Generated CxF file: {len(xml_bytes):,} bytes ({len(xml_bytes) / 1024 / 1024:.1f} MB)"
)
return xml_bytes

Expand Down Expand Up @@ -177,8 +177,8 @@ def benchmark_parsing_performance(num_samples: int) -> dict[str, float | int]:
cpu_count = psutil.cpu_count()
memory_info = psutil.virtual_memory()

print(f"System: {cpu_count} CPU cores, {memory_info.total/1024**3:.1f} GB RAM")
print(f"File size: {len(cxf_data):,} bytes ({len(cxf_data)/1024/1024:.1f} MB)")
print(f"System: {cpu_count} CPU cores, {memory_info.total / 1024**3:.1f} GB RAM")
print(f"File size: {len(cxf_data):,} bytes ({len(cxf_data) / 1024 / 1024:.1f} MB)")

# Benchmark 1: Parsing with schema validation
print("\n1. Parsing with schema validation...")
Expand All @@ -203,7 +203,7 @@ def benchmark_parsing_performance(num_samples: int) -> dict[str, float | int]:
f" Objects parsed: {len(cxf_obj.resources.object_collection.object_value):,}"
)
print(
f" Throughput: {len(cxf_obj.resources.object_collection.object_value)/parse_time_with_validation:.0f} objects/second"
f" Throughput: {len(cxf_obj.resources.object_collection.object_value) / parse_time_with_validation:.0f} objects/second"
)

# Clear memory
Expand Down Expand Up @@ -232,7 +232,7 @@ def benchmark_parsing_performance(num_samples: int) -> dict[str, float | int]:
f" Objects parsed: {len(cxf_obj.resources.object_collection.object_value):,}"
)
print(
f" Throughput: {len(cxf_obj.resources.object_collection.object_value)/parse_time_without_validation:.0f} objects/second"
f" Throughput: {len(cxf_obj.resources.object_collection.object_value) / parse_time_without_validation:.0f} objects/second"
)

# Performance comparison
Expand All @@ -243,10 +243,10 @@ def benchmark_parsing_performance(num_samples: int) -> dict[str, float | int]:
)
print(f" Speedup without validation: {speedup:.2f}x")
print(
f" Data throughput (with validation): {len(cxf_data)/1024/1024/parse_time_with_validation:.1f} MB/second"
f" Data throughput (with validation): {len(cxf_data) / 1024 / 1024 / parse_time_with_validation:.1f} MB/second"
)
print(
f" Data throughput (without validation): {len(cxf_data)/1024/1024/parse_time_without_validation:.1f} MB/second"
f" Data throughput (without validation): {len(cxf_data) / 1024 / 1024 / parse_time_without_validation:.1f} MB/second"
)

return {
Expand Down
2 changes: 1 addition & 1 deletion utilities/export_todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def extract_todo_items(root_directory: str) -> dict:

if in_todo and line.startswith("#"):
todo_item.append(line.replace("#", "").strip())
elif len(todo_item):
elif todo_item:
key = filename.replace("../", "")
if not todo_items.get(key):
todo_items[key] = []
Expand Down
Loading