Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Implement DataSource.get_contiguous_time_periods() #256

Merged
merged 3 commits into from
Oct 21, 2021

Conversation

JackKelly
Copy link
Member

Pull Request

Description

This is a bite-sized part of a larger issue (#223).

The ultimate aim of #223 is to change the way nowcasting_dataset computes the set available datetimes across all DataSources.

This PR basically just implements one function and its test: DataSource.get_contiguous_time_periods().

There are a few other little bits-and-bobs (which, if I was being really well behaved, would be in separate PRs!)

  • There are also some small formatting tweaks (mostly fixing lines > 100 characters).
  • Removed the ancient "temporary code" from DataSource.get_locations_for_batch() which could silently create nasty bugs in our prepared data batches!

How Has This Been Tested?

The PR implements a new unit-test. All tests pass.

  • No
  • Yes

Checklist:

  • My code follows OCF's coding style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked my code and corrected any misspellings

@peterdudfield
Copy link
Contributor

Looks good, very good to break it into a small PR.

raise NotImplementedError()
Raises:
NotImplementedError if this DataSource has no concept of a datetime index.
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

worth adding a logging statement?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question! TBH, if someone tries to call this function in the wrong context then that suggests a major mistake, so we probably want the code to blow up noisily (i.e. to throw an exception). So, if it's OK, I'll leave it like this for now, and we can see how we get on?

@JackKelly JackKelly merged commit 4d01e8a into main Oct 21, 2021
@JackKelly JackKelly deleted the jack/get_contiguous_time_periods branch October 21, 2021 06:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get intersection of _Periods_ of available data across all DataSources, instead of using datetimes.
2 participants