-
Notifications
You must be signed in to change notification settings - Fork 35
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
WIP: Allow Indexing into a Variable/Parameter with a Year #551
Conversation
@davidanthoff @rjplevin here's a first pass at these, I will go back over it and see if I can make things clearer or faster, as well as add tests and docs, but for now wanted to get the general ideas down and see what you guys think? |
Codecov Report
@@ Coverage Diff @@
## master #551 +/- ##
==========================================
- Coverage 83.81% 82.75% -1.06%
==========================================
Files 27 27
Lines 2125 2180 +55
==========================================
+ Hits 1781 1804 +23
- Misses 344 376 +32
Continue to review full report at Codecov.
|
Just to record what we decided in our meeting today: we'll have two new types, one called |
I was still feeling unsure about these type names, |
@ckingdon95, I see it slightly differently. The problem is that we have two conceptually different arguments, both integers, that we want to distinguish. If we define:
we've effectively created two new type-system-distinguishable integers. So I don't see P.S. Yes, you can have keyword args on constructors! |
Ah I see. If we are creating two different types then that makes sense. I thought that both of these would create the |
We should probably make it struct TimestepValue{T}
value::T
end so that one isn't limited to |
Agreed about type parameterization. As we've discussed, a time value, e.g., 2005, cannot be used without reference to the actual time dimension definition. So I don't see how If we define these as you discussed on the call, with an offset field, e.g., struct TimestepValue{T1, T2}
value::T1
offset::T2
end
struct TimestepIndex{T1, T2} # actually, mustn't these both always be Ints?
value::T1
offset::T2
end then the add/subtract functions just operate on the offset. The whole thing is ultimately interpreted w.r.t. a given time dimension. |
Yes, exactly, And yes, I think the fields in the |
Does |
That sounds right. I suppose we could also say that if it's an |
Maybe it should be: struct TimestepValue{T}
value::T
offset::Int
end
struct TimestepIndex
index::Int
end Even less symmetrical, but maybe more clear? |
Yes, I think that is how it should look. |
This looks good to me, although @davidanthoff when you say that we can type parameterize
|
I think it has to do with what type is used when the user calls |
Agreed! |
@lrennels should we also add a |
We should call it something else since |
I think I would actually prefer that such a test is written as |
UPDATE: CLOSING THIS PR TO START FRESH
#549, #568, #337
This PR will handle a few different Issues related to indexing into a Variable or Parameter.
Base.:+
andBase.:-
methods for the two typesgetindex
methods toTimestepArray
,TimestepVector
, andTimestepMatrix
time_index