Skip to content

Comments

Fix TimeRange __contains__ and add Timestamp __float__#94

Merged
philipnbbc merged 3 commits intomainfrom
philipn-fix-contains-and-float
Feb 10, 2025
Merged

Fix TimeRange __contains__ and add Timestamp __float__#94
philipnbbc merged 3 commits intomainfrom
philipn-fix-contains-and-float

Conversation

@philipnbbc
Copy link
Contributor

Details

This PR:

  • Fixes TimeRange.__contains__ which wrongly returned False for TimeRange.from_str("[0:0_1:0)") in TimeRange.eternity() for example.
  • Adds support for TimeRange arg to TimeRange.__contains__, which is equivalent to using contains_subrange.
  • Adds a Timestamp.__float__ which simplifies and avoids typing issues when converting a TimeRange.length to a float.

Jira Issue

Jira URL: https://jira.dev.bbc.co.uk/browse/CLOUDFIT-5398

Related PRs

Where appropriate. Indicate order to be merged.

Links to external test runs/working deployment

Where appropriate, if separate to default CI run

Submitter PR Checks

(tick as appropriate)

  • PR completes task/fixes bug
  • Tests exercise code appropriately
  • New features and API breaks are flagged in commit messages using magic strings
  • Documentation updated (README, Confluence, Docstrings, API spec, Engineering Guide, etc.)
  • Downstream repos have been checked for potential breaks & fixed as needed
  • APIs/UIs/CLIs updated as required
  • PR added to Jira Issue
  • Follow-up stories added to Jira
  • Any temporary code/configuration removed (e.g. test deployment environment, temporary commontooling branch)
  • Any pins against pre-releases have been removed

Reviewer PR Checks

(tick as appropriate)

  • PR completes task/fixes bug
  • Tests exercise code appropriately
  • Design makes sense, and fits with our current code base
  • Code is easy to follow
  • PR size is sensible
  • Commit history is sensible and tidy

Info on Cloudfit PRs

Philip de Nier added 3 commits February 5, 2025 14:03
Call `contains_subrange` to ensure correctness and consistency

sem-ver: bugfix
This allows float(Timestamp) to be used instead of Timestamp.to_float.
This helps to convert TimeRange.length into a float in one go by doing
float(TimeRange.length).

sem-ver: feature
@philipnbbc philipnbbc requested a review from a team as a code owner February 5, 2025 14:57
@j616 j616 self-assigned this Feb 10, 2025
Copy link
Contributor

@j616 j616 left a comment

Choose a reason for hiding this comment

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

LGTM

@philipnbbc philipnbbc merged commit 2bbdbc7 into main Feb 10, 2025
3 checks passed
@philipnbbc philipnbbc deleted the philipn-fix-contains-and-float branch February 10, 2025 16:23
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