-
Notifications
You must be signed in to change notification settings - Fork 65
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
Creating an IntervalCollection of ValueIntervals #674
Comments
You can easily create an
As you can see, the type of stored intervals is now just a list of the super interface
So this limitation is baked into the available type parameters of Alternatives:However, Time4J has another type of interval collection which indeed knows what kind of intervals are stored, namely: If you need to manipulate interval boundaries and know how to aggregate associated values of intervals during manipulation process then you might apply a combination of both Until now, I have no special API for aggregating values of value intervals. This phase is still up to you. You might also consider the various streaming methods of class If you think there is need for such an aggregator-API then let me know about your concrete proposals or suggestions. |
Thanks Meno for the explanation. I think sometimes we will need to have a collection of value intervals and I will need to modify the intervals (or at least produce a new collection out of the existing one). Furthermore, I would think that a collection of value intervals should not overlap because the meaning is not clear. If I want multiple values for a period I would rather use a collection of values for the Value attribute of the interval. The use case as explained initially is to model time series data - we want to tag a value (or some values) to a period to indicate that value is effective during that period. So I think one way is to have something like a ValueIntervalCollection that handles such requirements. I have not studied the API in details so I am not sure at this moment how ValueIntervalCollection should be related to IntervalCollection. We are working on a project so we can work out something during our project to enhance IntervalCollection along this line of thought, and then we can submit a PR. What do you think? |
If I understand you correctly then we can define a time series as temporally ordered sequence of non-overlapping value intervals (with gaps only when we don't have defined values) This would be a nice enhancement of Time4J. So I would welcome a PR as start. Personally I think, that such a time series will rather not be directly related to
For naming reasons, we could consider the name "IntervalSeries" for the new class (with same prefix like the other collection types for easier API-search and higher recognition value). Furthermore:
The About the features of such series-classes: Search operations probably based on binary search through the internal interval list, update operations might replace existing value intervals with new value intervals (that is setting a new value for a given time interval avoiding overlaps). Most of these functionality can be implemented in the super class For comparison, we can also look at APIs like JFreeChart. That API does not do much more than described here and unfortunately uses mutable classes while I would strongly prefer immutable classes (as done throughout Time4J). |
Agree with what you suggest in general. I am looking at how to build IntervalSeries and its sub-classes, and I have a question: Why is it that ChronoInterval has sub-classes like DateInterval, but ValueInterval does not have sub-classes like DateValueInterval? If so, when implementing DateIntervalSeries one can use DateValueInterval directly. |
About your question why I just wanted to limit the count of interval types, and the class But of course, you can create your own value intervals implementing the interface About interval series versus date series: After I have done some research about time series concepts in general, I would ask you if your value intervals might have some gaps or not. Background of the question is: If gaps can never occur in your model then it is also possible to realize a |
Hi,
Thanks for creating the library. It is what I need for date ranges manipulation.
I would like to use ValueInterval and IntervalCollection to model intervals that have an associated value (attributes of an entity that carries that value for during that interval - time series data e.g. interest rates).
However, I could not find a way to create an IntervalCollection from a list of ValueIntervals. Is there a way to do so? Thanks.
The text was updated successfully, but these errors were encountered: