Skip to content

Remove dead code, fix correctness bugs, implement sign_rev#59

Open
dpsanders wants to merge 2 commits into
masterfrom
cleanup-dead-code-and-fixes
Open

Remove dead code, fix correctness bugs, implement sign_rev#59
dpsanders wants to merge 2 commits into
masterfrom
cleanup-dead-code-and-fixes

Conversation

@dpsanders
Copy link
Copy Markdown
Member

Summary

  • Delete dead / broken code: src/decorated.jl (references DecoratedInterval which no longer exists in IntervalArithmetic v1), src/pave.jl (pre-Julia-1.0 syntax), src/powers.jl (square!/cube! were unused and the cube_pos implementation is explicitly marked "not rigorous"), examples/examples.jl (references a non-existent square function), and a stray test/Non1788tests/script.jl. Also remove unused mutating helpers exp!, log!, asin!.
  • Fix correctness bugs:
    • asin_rev was ignoring its input x argument. Example: asin_rev([0,1], [0,0.5])[2] returned [0, 0.841]; now correctly returns [0, 0.5].
    • max_rev/min_rev now return all-empty when a, b, or c is empty, and guard interval(lo, hi) construction against lo > hi via a small helper. Removes ~9 of the ~10 ill-formed-interval warnings that test runs were emitting.
  • Implement sign_rev. The previous body was commented out with broken syntax while still exported. New implementation: sign(x) ∈ {-1, 0, 1}, so the preimage of a is the union of half-lines / {0} depending on which of those values lie in a.
  • Docstring cleanup: "byt default" → "by default" (10 sites); cosh_rev/tanh_rev docstrings previously said "Reverse square root"; add default x = entireinterval(b/a) to pow_rev1/pow_rev2, matching what their docstrings already claimed.

Net: +111 / −289 lines across 14 files (5 deleted, 1 added, rest modified).

Test plan

  • Pkg.test() passes: 1355 pass (was 1344), 241 broken (same baseline as before)
  • 11 new sign_rev tests added in test/Non1788tests/sign.jl covering empty input, empty output, singleton cases (+1, -1, 0), two-value combinations, and restriction by a bounded b.
  • Two Non1788 extrema tests that asserted the buggy min_rev/max_rev empty-a behavior were updated to expect emptyinterval(); flagged in the review as incorrect expectations.
  • Ill-formed-interval warnings during the test run: reduced from ~10 to 1.

Not addressed here (follow-ups)

  • sin!/cos!/tan! are kept because sin_rev/cos_rev/tan_rev route through them via periodise. Making them private / inlining is a larger refactor.
  • div_rev does not yet handle 0 ∈ a with extended_div (analogous to what mul_rev already does).
  • min_rev/max_rev logic beyond the empty-input guard wasn't rewritten; the existing branch logic is ad-hoc and doesn't achieve tight enclosures in all cases. Recommended to revisit against Goualard (2008, hal-00288457).

🤖 Generated with Claude Code

dpsanders and others added 2 commits April 19, 2026 19:23
Delete unreferenced files and helpers:
- src/decorated.jl (not included; references DecoratedInterval, which
  no longer exists in IntervalArithmetic v1)
- src/pave.jl (pre-Julia-1.0 syntax; not included)
- src/powers.jl (square!/cube!/constant_contractor; unused)
- examples/examples.jl (references a non-existent square function)
- test/Non1788tests/script.jl (scratch file not in runner)
- exp!/log!/asin! mutating helpers (unused by any *_rev function)
- Dead #= ... =# body of sign_rev and its export

Fix correctness bugs:
- asin_rev now intersects x_new with the input x (was ignoring it,
  so x_new could exceed a tighter input bound)
- max_rev/min_rev return all-empty when a, b, or c is empty; guard
  interval(lo, hi) construction against lo > hi (removes ~9 of the
  10 ill-formed-interval warnings during the test run)

Docstring cleanup:
- "byt default" -> "by default" (10 sites)
- cosh_rev / tanh_rev docstrings said "Reverse square root"
- Add default x = entireinterval(b/a) to pow_rev1/pow_rev2, matching
  their docstrings

Test suite unchanged (1344 pass, 241 broken). Two Non1788 tests that
asserted the buggy min_rev/max_rev empty-a behavior were updated to
expect emptyinterval().

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The previous sign_rev body was commented out with broken syntax while
still being exported. Replace it with a working implementation:

sign(x) ∈ {-1, 0, 1} for real x, so the preimage of an interval `a`
under sign is determined by which of those three values lie in `a`.
Include 1 → positive half-line, include 0 → {0}, include -1 → negative
half-line. The tight outer enclosures are [0, ∞), [0, 0], (-∞, 0].

Also move _build_interval from trig.jl to the main module so arithmetic.jl
can use it, and add sign_rev tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant