Skip to content

Conversation

lrennels
Copy link
Collaborator

@lrennels lrennels commented Apr 13, 2021

#808 and #805

@codecov
Copy link

codecov bot commented Apr 13, 2021

Codecov Report

Merging #811 (eb1aeae) into master (fc923ef) will increase coverage by 0.29%.
The diff coverage is 98.96%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #811      +/-   ##
==========================================
+ Coverage   83.96%   84.25%   +0.29%     
==========================================
  Files          39       39              
  Lines        3479     3551      +72     
==========================================
+ Hits         2921     2992      +71     
- Misses        558      559       +1     
Flag Coverage Δ
unittests 84.25% <98.96%> (+0.29%) ⬆️

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

Impacted Files Coverage Δ
src/core/model.jl 87.50% <ø> (ø)
src/core/types/defs.jl 80.72% <ø> (-0.23%) ⬇️
src/core/defs.jl 87.53% <97.05%> (+0.29%) ⬆️
src/core/build.jl 100.00% <100.00%> (ø)
src/core/connections.jl 89.82% <100.00%> (+1.47%) ⬆️
src/core/dimensions.jl 88.88% <100.00%> (+3.64%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fc923ef...eb1aeae. Read the comment docs.

@lrennels lrennels marked this pull request as ready for review April 19, 2021 21:14
"""
function _check_first_last(obj::Union{Model, ModelDef}; first::NothingInt = nothing, last::NothingInt = nothing)
times = time_labels(obj)
!isnothing(first) && !(first in times) && error("The first index ($first) must exist within the model's time dimension $times.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like this way of checking conditions to throw an error, without writing the whole if-then!

new_last = last(new_keys)

# (1) check that the shift is legal
if isa(obj, ModelDef)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a thought: I get that we want different error messages for model vs component, but it feels a little weird to have identical sets of checks. Is there a chance that time shifts on the two will behave differently in the future, or is it too awkward to just format the text depending on model vs component?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch I agree, probably just a relic of thinking they'd need to be more different than they are


else # variable timesteps
start_idx = 1 # can be assumed since we cannot move the time forward
new_last < curr_last ? end_idx = findfirst(isequal(curr_last), new_keys) : end_idx = length(curr_keys)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should the first return value instead be "findfirst(isequal(new_last), curr_keys)"? It looks like we're looking for how much of curr_keys ought to be retained in the case where the new values end before the current values. Which would be the portion of it that goes until the new ending.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nice catch you're right!

@lrennels lrennels requested a review from arnavgautam April 21, 2021 18:38
Copy link
Collaborator

@arnavgautam arnavgautam left a comment

Choose a reason for hiding this comment

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

Looks good!

@lrennels lrennels merged commit 01e3228 into master Apr 22, 2021
@lrennels lrennels deleted the time-dims branch April 22, 2021 01:02
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