Lint cleanup: ruff fixes across entire codebase
- Strip trailing whitespace from all Python files - Fix import sorting (I001) across all modules - Convert Optional[X] to X | None syntax (UP045) - Remove unused imports (F401) - Convert lambda assignments to def functions (E731) - Add TYPE_CHECKING import for forward references - Update pyproject.toml ruff config: - Move select/ignore to [tool.ruff.lint] section - Add per-file ignores for DCT colorspace naming (N803/N806) - Add per-file ignores for __init__.py import structure (E402) - Exclude defunct test_routes.py - Remove frontends/web/test_routes.py (defunct debug snippet) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -51,30 +51,30 @@ print("Testing scipy DCT...")
|
||||
try:
|
||||
from scipy.fftpack import dct, idct
|
||||
import numpy as np
|
||||
|
||||
|
||||
# Create test array
|
||||
test = np.random.rand(8, 8).astype(np.float64)
|
||||
print(f"Input array shape: {test.shape}, dtype: {test.dtype}")
|
||||
|
||||
|
||||
# Test 1D DCT
|
||||
row = test[0, :]
|
||||
result = dct(row, norm='ortho')
|
||||
print(f"1D DCT result shape: {result.shape}, dtype: {result.dtype}")
|
||||
|
||||
|
||||
# Test 2D DCT (the potentially problematic operation)
|
||||
result2d = dct(dct(test.T, norm='ortho').T, norm='ortho')
|
||||
print(f"2D DCT result shape: {result2d.shape}, dtype: {result2d.dtype}")
|
||||
|
||||
|
||||
# Test inverse
|
||||
recovered = idct(idct(result2d.T, norm='ortho').T, norm='ortho')
|
||||
error = np.max(np.abs(test - recovered))
|
||||
print(f"Round-trip error: {error}")
|
||||
|
||||
|
||||
if error < 1e-10:
|
||||
print("✓ scipy DCT working correctly")
|
||||
else:
|
||||
print("⚠ scipy DCT has precision issues")
|
||||
|
||||
|
||||
except Exception as e:
|
||||
print(f"✗ scipy DCT failed: {e}")
|
||||
import traceback
|
||||
@@ -90,11 +90,11 @@ try:
|
||||
from scipy.fftpack import dct, idct
|
||||
import numpy as np
|
||||
import gc
|
||||
|
||||
|
||||
# Simulate processing many 8x8 blocks
|
||||
large_array = np.random.rand(512, 512).astype(np.float64)
|
||||
print(f"Large array shape: {large_array.shape}, size: {large_array.nbytes} bytes")
|
||||
|
||||
|
||||
count = 0
|
||||
for y in range(0, 512, 8):
|
||||
for x in range(0, 512, 8):
|
||||
@@ -103,14 +103,14 @@ try:
|
||||
recovered = idct(idct(dct_block.T, norm='ortho').T, norm='ortho')
|
||||
large_array[y:y+8, x:x+8] = recovered
|
||||
count += 1
|
||||
|
||||
|
||||
print(f"Processed {count} blocks successfully")
|
||||
|
||||
|
||||
del large_array
|
||||
gc.collect()
|
||||
|
||||
|
||||
print("✓ Large array processing completed")
|
||||
|
||||
|
||||
except Exception as e:
|
||||
print(f"✗ Large array processing failed: {e}")
|
||||
import traceback
|
||||
@@ -125,26 +125,26 @@ print("Testing PIL with large image...")
|
||||
try:
|
||||
from PIL import Image
|
||||
import io
|
||||
|
||||
|
||||
# Create a large test image
|
||||
img = Image.new('RGB', (4000, 3000), color=(128, 128, 128))
|
||||
|
||||
|
||||
# Save to bytes
|
||||
buffer = io.BytesIO()
|
||||
img.save(buffer, format='PNG')
|
||||
img_bytes = buffer.getvalue()
|
||||
print(f"Test image size: {len(img_bytes)} bytes")
|
||||
|
||||
|
||||
# Re-open and process
|
||||
buffer2 = io.BytesIO(img_bytes)
|
||||
img2 = Image.open(buffer2)
|
||||
print(f"Re-opened image: {img2.size}, mode: {img2.mode}")
|
||||
|
||||
|
||||
# Convert to numpy array
|
||||
import numpy as np
|
||||
arr = np.array(img2)
|
||||
print(f"NumPy array: {arr.shape}, dtype: {arr.dtype}")
|
||||
|
||||
|
||||
# Clean up
|
||||
img.close()
|
||||
img2.close()
|
||||
@@ -152,9 +152,9 @@ try:
|
||||
buffer2.close()
|
||||
del arr
|
||||
gc.collect()
|
||||
|
||||
|
||||
print("✓ PIL large image test completed")
|
||||
|
||||
|
||||
except Exception as e:
|
||||
print(f"✗ PIL test failed: {e}")
|
||||
import traceback
|
||||
|
||||
Reference in New Issue
Block a user