-
Notifications
You must be signed in to change notification settings - Fork 35
Timestep Indexing #580
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
Timestep Indexing #580
Conversation
We shouldn't deprecate Int indexing until we also have |
Sure @ckingdon95 do you want to add those changes to this PR? Seems like it might make sense to put them in one? |
Do we need to add comparison methods for these new types now? So that users can compare the AbstractTimestep function run_timestep(p, v, d, t)
if t < TimestepIndex(10) ...
if t == TimestepValue(2100) ...
end |
I had the same question and wanted to bring that up with you and @rjplevin @davidanthoff. I think adding those methods would probably be doable, but I was getting a little bit confused on use cases because we did employ these primarily for indexing purposes. It seems a little strange to compare For example, we already have the functions below to help with comparisons ... so what are the use cases here? Do the intersect? Are there new ones?
|
My guess is that we might want to remove |
Yea I was thinking that we probably don't want both of those options, but I'm not sure yet which I like. As you say, the current way doesn't allow for less/greater than with operators, but you could do that with |
@lrennels I ended up doing a separate PR for the |
@ckingdon95 are we deprecating any of the |
@rjplevin @ckingdon95 uhoh Houston we may have a problem that needs some creativity ... our crucial
|
I think yes, we want to also remove the Regarding the
I think I prefer option 1, but we definitely need @rjplevin to weigh in here! |
Those are all good options to consider. I'd hate to spoil the clean code by introducing a function call rather than splatting the indices, so I prefer #1, returning TimestepIndexes, though we may have to provide some Colon support function for this to work. Not sure.... Let's see if it hurts performance appreciably before we optimize. |
Alright I agree and plan to implement #1. I'm almost there, and have added a
The options I see are to either
which does come with it's own challenges since it requires some flexible splitting deepening how many dimensions we have. Maybe there is a fancy Julia way to do that. |
@lrennels And in response to your other question, I also think we need to implement the It also looks like some changes need to be made to the test file that's been modified ("test_timesteparrays.jl"). Some new lines have been added to test the new methods, but this has messed up tests that come later that test for certain values that have been reset by the new tests. (ex: lines 52 then 70) |
Codecov Report
@@ Coverage Diff @@
## master #580 +/- ##
==========================================
+ Coverage 77.48% 79.06% +1.57%
==========================================
Files 39 39
Lines 2572 2718 +146
==========================================
+ Hits 1993 2149 +156
+ Misses 579 569 -10
Continue to review full report at Codecov.
|
Alright team @davidanthoff @rjplevin @ckingdon95 this beast of a PR (although nothing compared to composite components!) is ready to be reviewed. Tests are passing, lots of methods and tests have been added, etc. I'm putting #337 in a different PR it's too much for this one |
@lrennels I just noticed that the CodeCov report doesn't look great in terms of how much of the new code isn't being tested. I think we should probably make sure that every method you added gets a test |
fiiiiiiine |
This PR replaced #551, don't merge until after @ckingdon95 's #581
Addresses Issues #549, #568
This PR will handle a few different Issues related to indexing into a Variable or Parameter.
TimestepValue
Base.:+
andBase.:-
methods to add/subtract an IntBase.getindex
andBase.setindex!
TimestepArray
with an array ofTimestepValue
s - not for nowarr[TimstepValue(2000):TimestepValue(2005), 3]
- not possible without the context of theTimestepArray
TimestepIndex
Base.:+
andBase.:-
methods to add/subtract an IntBase.getindex
andBase.setindex!
TimestepArray
with an array ofTimestepIndex
s (see need in updated_param_indices
functionarr[TimestepIndex(1):TimestepIndex(5), 3]
Base.getindex
andBase.setindex
methods deprecate Int indexing for timesteps #568 ... should make the warning include stack trace info!TimestepArray
'stime
dimension with a:
(see need in_param_indices
special case)