-
-
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
Implement Image interface #994
Conversation
Just to summarize a discussion I had with Philipp on gitter regarding the first question:
We agreed that this is a reasonable approach as long as the tolerance is about avoiding machine precision issues only and not some fuzzy ad hoc tolerance to be tweaked by the user. For instance, instead of 10e-9 a suitable value should be determined for the system, e.g using the sys.float_info. |
Again summarizing our discussion on gitter:
I agree that a future PR supporting multiple vdims in the data API would be very welcome but for now, we can extend |
3af6cdd
to
30b9a12
Compare
Now based off #1075 and now slowly reaching API compatibility. Still missing a sample implementation otherwise largely complete. Should also add a lot more unit tests for grid interfaces, which will also cover the new Currently I'm also still a bit unclear what to do about Raster itself. It could probably be unified with Image by simply adding integer indices in the constructor, but that would also make |
Raster is now unified with the image interface. Now I'll have to refactor QuadMesh so it still works independently. Hopefully we'll manage to write interfaces to handle 1D and 2D binned data, e.g. for Histogram and QuadMesh, as part of 1.8. |
128a304
to
dd9c36a
Compare
dd9c36a
to
9407a51
Compare
tests/testellipsis.py
Outdated
|
||
def test_raster_ellipsis_slice_value_missing(self): | ||
data = np.random.rand(10,10) | ||
try: | ||
hv.Raster(data)[...,'Non-existent'] | ||
except Exception as e: | ||
if str(e) != repr("'z' is the only selectable value dimension"): | ||
print(e) |
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.
Don't forget to remove.
1cd4a2f
to
c215b2f
Compare
7736826
to
fa4e944
Compare
e39ea4f
to
a7a6b23
Compare
Ready for final review and merging once test pass. |
Nevermind still need to make a few changes. |
25dcba9
to
8e31fff
Compare
f0f6b0b
to
29a1e17
Compare
Ready to merge again, some issues reindexing gridded datasets cropped up but are fixed now. |
holoviews/core/util.py
Outdated
""" | ||
Computes a bounding range from a number of evenly spaced samples. | ||
Will raise an error if samples are not evenly spaced within | ||
tolerance. |
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.
I would just mention which tolerance - namely as reported by sys.float_info
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.
No longer raises an error, so yeah will fix it.
@@ -52,6 +43,54 @@ def compute_edges(edges): | |||
return np.concatenate([edges, [edges[-1]+width]]) | |||
|
|||
|
|||
def compute_slice_bounds(slices, scs, shape): |
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.
Nice to have this code split out as a utility.
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.
I'm not sure I would recommend adding tests for this utility right now as I do want to merge ASAP. At least it is much easier to test now!
Looks good. I made one comment about a docstring - other than that, I'll merge when you tell me it is ready (and the tests are green). |
Already pushed the updated docstring, just waiting on tests now. |
All tests are green! 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. |
This PR is a WIP in implementing an interface to allow
Image
Elements to subclassDataset
and use the other interfaces, replacingGridImage
. There are a few things to be settled so I'm hoping to discuss these in this PR.Our Image types need bounds. When you pass in an array the bounds are required, but when using the xarray and grid interfaces, the bounds should be computed from the data. Currently I deduce the bounds by asserting that all samples must be evenly spaced with a small tolerance (10e-9). Eventually we'll have QuadMesh for non-equal spacing, but that will require some more work. Does this sound reasonable?
Dataset does not have an interface to access multiple value arrays at once. This makes it difficult to access RGB and HSV data. We can either accept the overhead of stacking and unstacking these arrays and provide a convenient property on RGB/HSV elements to do this for us, or come up with a general API on the interfaces to get the stacked arrays. There was also the suggestion that other interfaces could support holding stacked value dimension arrays instead of holding them as unstacked arrays per value dimension but that could happen in a later PR.