tdd-cleanup-extraction #1

Merged
jez merged 10 commits from tdd-cleanup-extraction into master 2026-07-01 20:35:48 +00:00
Owner
No description provided.
jez added 10 commits 2026-07-01 20:35:34 +00:00
- pyproject.toml with pytest config
- tests/ directory with conftest.py (seeded RNG fixture, sys.path setup)
- test_transforms.py: 134 tests covering all 16 transforms
  - Determinism (same seed + same input = same output)
  - Cross-instance seed determinism
  - Output shape for 5 test points per transform
  - Singularity handling (ZeroDivisionError at origin)
  - Specific behavior tests (Moebius/InverseJulia complex, Spherical div-by-zero)
  - get_name() returns class name
  - Bubble, Sinusoidal, Swirl, Ex output range checks
21 tests covering:
- Transform base: get_name, colour averaging (half-black, half-white)
- ComplexTransform: f(z) bridge to transform(px, py)
- MoebiusBase: naming (MoebX), composition, determinism, colour delegation
- SphericalBase: naming (SpheriX), composition, double-spherical, determinism
- Extract box_filter_colour(current_rgb, transform_rgb) → (r,g,b)
  from Transform.transform_colour. Pure function, no state, no RNG.
- 8 tests: black+white, identical, black+black, channel independence,
  determinism, output range (100 random values), commutativity, identity
- Transform.transform_colour now delegates to box_filter_colour
  preserving full backward compatibility
- Add IFS.from_config(rng, transform_instances) static factory that
  bypasses the reflection-based transform discovery in __init__
- 16 tests covering:
  - from_config: creation, weights, total_weight, empty list
  - choose_transform: returns from list, proportional weights,
    single transform, empty list returns None
  - final_transform: zero identity, scale-by-half, deterministic, shape
  - add_transform: appends, positive weight, multiple, seed-deterministic
Extracted pure functions with type annotations:
- ward_scalefactor(data, width, height, iterations) — Ward's 1994 formula
- gamma_encode_pixel(value, scalefactor, iterations) — gamma correction
- black_ratio(data) — sparse detail metric (total/black_count)
- colour_ratio(data) — gradient smoothness metric (unique/total)
- interest_factor(data) — combined visual appeal heuristic

Image class methods now delegate to module-level functions.
26 tests covering scalefactor properties, gamma encoding, black/colour ratios,
interest factor behaviors, and determinism.
8 tests covering: positive values, zero (caught ValueError → 0.0),
negative inputs (→ 0.0), very small positive, sub-unit values,
large values, integer inputs, near-machine-epsilon values.
- New cli.py module replacing pyifs.py's getopt + PySimpleGUI entry point
- argparse-based: --seed, -w/--width, -H/--height, --iterations, --num-points,
  --num-transforms, --moebius-chance, --spherical-chance, -o/--output,
  -n/--count, --exclude, --include, --verbose, --version
- parse_transform_filter() helper for comma-separated include/exclude lists
- headless batch mode with seed auto-generation
- 23 tests: argument parsing, defaults, short/long forms, combined options,
  main() end-to-end with file output verification
- Also fixed image.py: tostring() → tobytes() (removed in Python 3.12+)
- Add save_pillow() method using PIL.Image for PNG output
- Refactor save() to delegate to save_pillow() (backward compatible)
- Remove output_chunk() and unused struct/zlib imports
- 5 tests: valid PNG creation, deterministic output, black image,
  non-square images, legacy save() compatibility
- All 241 tests pass
- pyifs.py now delegates to cli.main() (backward compatible entry point)
- All 241 tests pass
- Added __pycache__/, *.pyo for Python 3 compatibility
- Added .pytest_cache/ and test_output/ for new test infrastructure
- Added .DS_Store, Thumbs.db for cross-platform hygiene
- Added coverage files (.coverage, htmlcov/)
- Added package build artifacts (egg-info, dist, build)
- Added virtual environment directories (.venv, venv, env)
- Preserved existing entries (best/, im/, data/, test.png) as-is
jez merged commit 025df0ef52 into master 2026-07-01 20:35:48 +00:00
jez deleted branch tdd-cleanup-extraction 2026-07-01 20:35:50 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
KrustyPlanet/pyifs!1
No description provided.