-
Notifications
You must be signed in to change notification settings - Fork 18
Fix/merge idx #172
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
Fix/merge idx #172
Conversation
Thanks, that looks good, I will have a closer look later. One thing that I noticed is the use of the generic |
Good point. I'll try to catch the relevant exceptions. |
A more cosmetic thing that I noticed is that we reuse these |
Is it possible that you introduced the idl = [np.nditer(o) if isinstance(o, np.ndarray) else o for o in idl] and to remove the I will think how to refactor the pattern. |
That might be the case. The other thing I could imagine are empty lists for which you would get an |
I guess we would want an exception to be thrown in the case where we pass an empty list ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CI fails because of wrong dependencies in the latest IPython release (ipython/ipython#14053). I will still merge this and hope that they resolve the issue soon.
This pr fixes two bugs:
When merging observables that are defined on different regular sets of configurations (i.e., the
idl
s beingrange
s), the old version of the code made an attempt to merge those smartly. However, the corresponding piece of code did not take into account all possible combinations, such that mergingrange(1, 1011, 2)
andrange(1, 1010, 1)
led torange(1, 1011, 1)
, clearly adding a configuration1010
that was not present before.The merge of
idl
s is now always performed viasorted(set().union(*idl))
when the sets of configurations differ. Afterwards, an attempt is made to check whether the resulting union can be expressed asrange
. The resulting overhead of this check is much smaller than the total time that is needed to merge observables that are based on different sets of configurations. Usingunion
certainly adds extra time compare to the previous (wrong) solution of merging, but I failed to find an analytical solution to either determine the range that describes the union of ranges or returns the list that describes the union in the most general cases. For the merge of matchingidl
, nothing has changed.A similar change has been applied to
_intersection_idx
to have the same, correct, definition of finding the union and intersection of a list ofidl
s.Some tests that had been written to check correctness have been wrong themselves. I corrected them and added a few more.
The second fix concerns an edge case where the solution of _calculate_drho for large time separations #157 did lead to an exception, since the list in
_calculate_drho
was missing an element.