Skip to content

Property tests use independent references instead of reimplemented calendar oracles - #52

Merged
dylanjm merged 1 commit into
anchored-finance-taxfrom
anchored-oracle-cleanup
Oct 15, 2026
Merged

dylanjm merged 1 commit into
anchored-finance-taxfrom
anchored-oracle-cleanup

Conversation

@j-bryan

@j-bryan j-bryan commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Related to #36 and #38 (closes neither). Stacked on #49, in stack #51. This PR changes no library behavior.

What changes

  • Property tests no longer reimplement DCAF's calendar logic. The helpers in tests/unit/strategies.py that copied DCAF's own calculations are removed: year_fraction, counted_days, calendar_windows, calendar_period_key, timing_point, tail_days, anchored_boundary, and is_month_end. The stream, day-count, and finance/tax tests now use one of the following for expected values:
    • hand calculations,
    • properties of the helper under test,
    • DCAF helpers that are themselves tested against hand values in the new tests/unit/test_time_helpers.py.
  • New day-count properties in test_day_count_convention.py: consecutive spans add up, actual/actual measures a calendar year as exactly 1, and actual/365-no-leap drops exactly Feb. 29.
  • _calendar_period_windows is now public as calendar_period_windows, because finance, project, and stream modules all use it. The change is a rename only.
  • Truncation reference cases: test_time_helpers.py checks values within 1e-13 of a whole day. Loosen the whole-day float tolerance to 1e-8 #53 adds the cases at the edges of its looser tolerance.
  • Anchored schedule boundaries with an end-of-month rule #45's and Debt, construction, depreciation, and PTC schedules use anchored dates #49's tests compare against add_periods instead of the removed anchored_boundary oracle. This also reformats one parametrize entry in test_finance_tax_anchoring.py that ruff format flagged.

Testing

uv run ruff check, uv run ruff format --check, uv run mypy dcaf/, and uv run pytest pass (1013 tests), and the Hypothesis properties also pass at 3,000 examples each.

🤖 Generated with Claude Code

@j-bryan
j-bryan added this pull request to stack #51 October 13, 2026 22:05
…ndent references

The stream, day-count, and finance/tax property tests no longer compare against helpers in
strategies.py that reimplement DCAF's calendar logic. Expected values now come from hand
calculations, properties of the helpers under test, or DCAF helpers that are themselves tested
against hand values in test_time_helpers.py. The calendar window helper is shared across
finance, project, and stream modules, so it is now public as calendar_period_windows.

Co-Authored-By: Claude <noreply@anthropic.com>

@dylanjm dylanjm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes are good and remove some slop.

@dylanjm
dylanjm merged commit d9c1735 into main Oct 15, 2026
1 check passed
@dylanjm
dylanjm deleted the anchored-oracle-cleanup branch October 15, 2026 15:11
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.

2 participants