-
-
Notifications
You must be signed in to change notification settings - Fork 404
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
Fixed bug unpacking Overlay and Layout objects in Layout.from_values #1088
Conversation
Just noticed that it's skipping |
With my latest fix the repr now looks correct.
Going to need a lot of unit tests. |
Looks good but I will wait to see examples of what the |
There's definitely still things going wrong. Will have to look into this more. |
8c3025e
to
6dfc903
Compare
Finally managed to resolve this, still some unit tests to add but the current notebook test failure in Showcase is real: freq1 = hv.Image(sine(grid, freq=50)) + hv.Curve(zip(dist, sine(dist**2, freq=50)))
freq2 = hv.Image(sine(grid, freq=200)) + hv.Curve(zip(dist, sine(dist**2, freq=200)))
(freq1 + freq2).cols(2) With the PR :Layout
.Image.I :Image [x,y] (z)
.Curve.I :Curve [x] (y)
.Image.II :Image [x,y] (z)
.Curve.II :Curve [x] (y) Without the PR: :Layout
.Image.I :Image [x,y] (z)
.Curve.I :Curve [x] (y)
.Image.II :Image [x,y] (z)
.Curve.III :Curve [x] (y) Hopefully this is the only thing that snuck in while our tests weren't running properly. |
I agree the new repr looks correct. Happy to merge once the tests are updated and passing. |
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.
It would still be nice to have examples of what the _unpack_paths
classmethod does in unit tests. Otherwise, I am happy to merge once the notebook tests are passing.
So I just checked out some old versions and it turns out the issue above, which is now been fixed, has always been there. |
So this code turned out to be quite a mess, the functionality was duplicated across two methods and spread out even further into various The new algorithm can be summed up in two steps:
Previously we had a separate method which would merge existing Overlay items by trying to make their paths unique. This approach did not really work (again note the example above), and made the code more complex. The issue is that merging existing paths cannot be done correctly without trying to figure out which parts of the existing paths are roman numerals which is bound to be brittle. In effect the results should either be more correct or the same (as evidenced by most of the tests passing), unless you construct Layouts or Overlays with custom paths, which is presumably fairly rare. We do use custom paths in |
8084606
to
fba8d29
Compare
I'm not sure that is a safe assumption. Could you give a simple example of how it was supposed to work before, how it actually worked (assuming it was buggy) and how it works now? My worry is that these changes could affect a lot of things and I want to understand the implications of this PR for backwards compatibility. |
When inheriting and merging custom paths in the previous implementation it would follow the following rule, cut the path down to length 2, if the second part of the path matches the label keep it, otherwise drop it. So the difference basically comes down to whether the first part of the path, corresponding to the object's group, is inherited or not. I can probably still make that work now that I've factored things out into smaller functions and can make sense of it. |
Okay I've reimplemented path inheritance which turned out to be much easier now that the code is factored into smaller chunks, some of which may be better as utilities. The behavior should now be the same as before except 1) numbering is correct and 2) it doesn't needlessly create a whole bunch of intermediate objects. |
Looks good! I'm happy to merge once the tests pass. I would also check that the new underscore methods don't show up when tab-completing on Layouts... |
Still missing a lot of unit tests, perhaps I'll also make some of the underscore methods into utilities. Doubt they'll show up as we already had a bunch of underscored methods before. |
Up to you! Might make good sense although if you have a bunch or related utilities, it might be worth defining them as classmethods on a utility class. |
a957e1d
to
8ff53b0
Compare
@jlstevens Finally got around to adding some unit tests here, previous unit tests were only testing all the simple cases, which is how we missed this in the past. Ready to merge now when tests pass. |
Looks good! This PR took a while but I am glad this issue is now fixed. The code looks easier to understand than before with the bonus of actually being more correct. Merging. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Fix for #1081, passing Layouts and Overlays to their respective constructors correctly unpacks them again after regression caused them to be nested.
This now correctly produces an object with this repr: