Skip to content

Reject missing nearest-observation targets - #431

Merged
thodson-usgs merged 2 commits into
DOI-USGS:mainfrom
qorud02:fix-missing-nearest-targets
Oct 1, 2026
Merged

thodson-usgs merged 2 commits into
DOI-USGS:mainfrom
qorud02:fix-missing-nearest-targets

Conversation

@qorud02

@qorud02 qorud02 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Missing target timestamps passed to get_nearest_continuous become invalid time >= 'nan' / time <= 'nan' CQL bounds, including when only one entry in a list is missing. Reject these targets with an actionable ValueError before calling get_continuous.

The change adds a missing-value check after timestamp normalization and documents the input requirement. Seven regression cases exercise scalar and supported container inputs and verify that the underlying getter is never called for missing targets.

Validation on Windows with Python 3.12.14 and pandas 3.0.1:

  • All seven new regression cases fail against the original source and pass with the fix; the nearest module has 41 passing tests.
  • Full offline suite: 1,179 passed, 5 skipped, 12 deselected.
  • Ruff lint and format, strict mypy, Xenon, complexipy, and all eight Import Linter contracts pass.
  • Windows coverage is 98.40% overall and 99.36% for nearest.py. Per the contributor guide, the Windows result is recorded with --fail-under=0; the Linux CI job still evaluates its 98.90% ratchet.

These API-boundary tests make no live USGS request.

Closes #430.

qorud02 and others added 2 commits October 1, 2026 21:46
Follow-up review changes on top of the missing-target fix (DOI-USGS#430):

- targets: report how many entries are missing and where the first is,
  listing every missing form (NaT, None, NaN, ''); ask for a timestamp
  rather than suggesting removal when nothing valid remains; reject
  numbers (read by pandas as epoch nanoseconds) with TypeError naming
  the units to convert from; rewrap pandas parse errors to name targets
  instead of suggesting a format= the getter does not accept.
- window: reject missing, negative, and unparseable windows with
  ValueError, and bare numbers with TypeError. A negative window used to
  invert every bound and return an empty frame; a missing one crashed
  with AttributeError. Zero remains an exact-match query.
- Messages follow the repo convention: parameter names bare, caller
  values as (got ...), and a remedy that works when pasted back.
- Docstring: describe window as how far either side of each target to
  search; document every raise.
- Tests grouped into targets and window validation sections; each
  suggested remedy is applied literally and must succeed.
- NEWS entry.

@thodson-usgs thodson-usgs 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.

Reviewed and extended with input validation for targets and window; CI green.

@thodson-usgs
thodson-usgs merged commit c7a356e into DOI-USGS:main Oct 1, 2026
11 checks passed
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.

Missing nearest-observation targets produce invalid CQL bounds

2 participants