Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce indexing and slicing of TimePartition #111

Merged
merged 8 commits into from
Mar 7, 2024

Conversation

jwallwork23
Copy link
Member

Closes #99.

Currently, indexing a TimePartition returns various pieces of information associated with that subinterval. The changes introduced in this PR are more logical, i.e., indexing gives a sub-TimePartition. Similarly for slicing.

@jwallwork23 jwallwork23 added the enhancement New feature or request label Feb 20, 2024
@jwallwork23 jwallwork23 added this to the Version 1 milestone Feb 20, 2024
@jwallwork23 jwallwork23 self-assigned this Feb 20, 2024
Copy link
Collaborator

@acse-ej321 acse-ej321 left a comment

Choose a reason for hiding this comment

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

@jwallwork23 - Looks straightforward and slicing will be useful.

I was wondering if the following line of code might also be impacted by the refactoring?

num_timesteps = self.time_partition[subinterval].num_timesteps
if num_timesteps > N:

@jwallwork23
Copy link
Member Author

Thanks @acse-ej321, good spot. In this snippet of code, we want to get the number of timesteps for a given subinterval.

This could be done by taking the sub-timepartition and evaluating num_timesteps, which sums num_timesteps_per_subinterval over all subintervals (in this case there is only one), which is what would be done with the snippet you quote.

An equivalent but perhaps clearer way is to just take the appropriate index of num_timesteps_per_subinterval, so that's what I've done in the latest commit 06da0ad.

(The pre-commit hook also seems to have put an unrelated formatting change in there, too.)

@jwallwork23 jwallwork23 merged commit 5350fec into main Mar 7, 2024
1 check passed
@jwallwork23 jwallwork23 deleted the 99_subtimepartition branch March 7, 2024 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support slicing TimePartition
2 participants