Skip to content

Conversation

@d-chambers
Copy link
Contributor

@d-chambers d-chambers commented Oct 4, 2025

Description

Implements a fix for #534.

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes.
  • documented the new feature with docstrings and/or appropriate doc page.
  • included tests. See testing guidelines.
  • added the "ready_for_review" tag once the PR is ready to be reviewed.

Summary by CodeRabbit

  • Bug Fixes

    • Improved plotting robustness when time coordinates contain NaN/NaT values by using sensible fallbacks for axis extents, preventing blank plots or errors.
    • Waterfall plots now render reliably even with incomplete or irregular time data.
  • Tests

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 4, 2025

Walkthrough

Updated plotting utilities to use NaN-safe min/max when computing extents with fallbacks for all-NaN inputs. Added a test validating waterfall plotting with incomplete time coordinates by aggregating chunked data and ensuring a matplotlib Axes is returned.

Changes

Cohort / File(s) Summary
Plotting NaN-safe extents
dascore/utils/plotting.py
Replace direct min/max with numpy nanmin/nanmax in timedelta/extent logic; add fallback to index-based extents when all values are NaN/NaT.
Waterfall test for incomplete time
tests/test_viz/test_waterfall.py
Add test_incomplete_time_coord to verify waterfall plotting works with aggregated, incomplete time coordinates (issue #534).

Suggested labels

bug

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The description only states “Implements a fix for #534” and leaves the template checklist blank, providing no information about the underlying issue, the changes made, how they address the problem, or what tests and documentation were added. Please expand the Description section to summarize the bug and the solution (e.g. replacing min/max with nanmin/nanmax and adding fallback logic), describe the new test, reference the issue in the checklist, confirm any docstring updates, and add the “ready_for_review” tag once complete.
Title Check ❓ Inconclusive The title “fix_534” is too terse and only references the issue number without summarizing what the change actually does, making it vague and non-descriptive for someone scanning the commit history. Please update the title to a concise sentence that describes the main change, for example “Handle NaN/NaT in plot extents with nanmin/nanmax fallback” so that the purpose of the PR is immediately clear.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix_534

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai bot added the bug Something isn't working label Oct 4, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
dascore/utils/plotting.py (1)

68-76: Robust handling of NaN/NaT values in coordinates.

The use of nanmin/nanmax with a fallback to index-based extents correctly handles the edge case of all-NaN/all-NaT coordinate arrays, preventing crashes as intended for issue #534.

Minor consideration: The fallback values (0, len(array)-1) are integers, which may cause minor type inconsistency when the original array is datetime64 or timedelta64. While the downstream conversion functions (_convert_datetimes, _convert_timedeltas) can handle integers, you might consider dtype-aware fallbacks (e.g., np.datetime64(0, 'ns') for datetime arrays) for more explicit type preservation. However, given this is an edge case and the current approach works, this is purely optional.

tests/test_viz/test_waterfall.py (1)

183-192: Test validates the fix for incomplete time coordinates.

The test successfully creates a scenario with aggregated time coordinates (NaN/NaT values) and verifies that waterfall() no longer crashes, addressing issue #534.

Consider optionally enhancing test coverage by:

  • Asserting that the plot extents fall back to index-based values (0 to N-1) when coordinates are all NaN
  • Verifying that the axis labels or other plot properties are correctly set despite missing coordinate data

However, the current test adequately validates the primary requirement (no crash with incomplete coordinates).

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d843736 and bf55206.

📒 Files selected for processing (2)
  • dascore/utils/plotting.py (1 hunks)
  • tests/test_viz/test_waterfall.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
dascore/utils/plotting.py (1)
dascore/utils/misc.py (1)
  • suppress_warnings (82-94)
tests/test_viz/test_waterfall.py (5)
dascore/core/spool.py (4)
  • spool (663-692)
  • chunk (94-141)
  • chunk (501-531)
  • viz (319-327)
dascore/examples.py (1)
  • get_example_spool (710-756)
dascore/utils/chunk.py (1)
  • chunk (429-471)
dascore/proc/aggregate.py (1)
  • max (112-135)
dascore/viz/waterfall.py (1)
  • waterfall (41-116)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (18)
  • GitHub Check: test_code (windows-latest, 3.12)
  • GitHub Check: test_code_min_deps (macos-latest, 3.12)
  • GitHub Check: test_code_min_deps (ubuntu-latest, 3.13)
  • GitHub Check: test_code_min_deps (windows-latest, 3.13)
  • GitHub Check: test_code (macos-latest, 3.12)
  • GitHub Check: test_code (macos-latest, 3.11)
  • GitHub Check: test_code (ubuntu-latest, 3.12)
  • GitHub Check: test_code_min_deps (ubuntu-latest, 3.12)
  • GitHub Check: test_code_min_deps (windows-latest, 3.12)
  • GitHub Check: test_code (windows-latest, 3.13)
  • GitHub Check: test_code (macos-latest, 3.10)
  • GitHub Check: test_code (windows-latest, 3.10)
  • GitHub Check: test_code (windows-latest, 3.11)
  • GitHub Check: test_code (macos-latest, 3.13)
  • GitHub Check: test_code (ubuntu-latest, 3.13)
  • GitHub Check: test_code (ubuntu-latest, 3.11)
  • GitHub Check: test_code (ubuntu-latest, 3.10)
  • GitHub Check: Run benchmarks

@codecov
Copy link

codecov bot commented Oct 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.92%. Comparing base (d843736) to head (bf55206).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #562   +/-   ##
=======================================
  Coverage   99.92%   99.92%           
=======================================
  Files         127      127           
  Lines       10616    10622    +6     
=======================================
+ Hits        10608    10614    +6     
  Misses          8        8           
Flag Coverage Δ
unittests 99.92% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 4, 2025

CodSpeed Performance Report

Merging #562 will not alter performance

Comparing fix_534 (bf55206) with master (d843736)

Summary

✅ 50 untouched

@d-chambers d-chambers merged commit f8d7949 into master Oct 4, 2025
24 checks passed
@d-chambers d-chambers deleted the fix_534 branch October 4, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants