-
Notifications
You must be signed in to change notification settings - Fork 2
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
Shape5D with floats? #11
Comments
I had no intentions of actually allowing non-integers in either This is needed to streamline the implementation of A Clearly this was not an obvious design decision, though =/ I'd be happy to hear any ideas of more elegantly solving this =) |
Hm. I don't think allowing +inf -inf is necessary to represent shapes. I guess it's your way of constructing a shape from start to stop that requires it. However, a shape itself should not have any axis with negative dimensions. What would this mean? I have seen that Shape5D is a Point5D subclass. Maybe that is not appropriate then. Or Point should be actually of Type
Why invent something here if the I think it's dangerous to sacrifice clarity of annotations. For me they are counter intuitive in this case. I see that |
And what about having negative start indices (valid slices), e.g. e.g.
This is all valid Python. But the result of |
Also I'd argue that |
As I read further down your comments, I realized that we were operating under different assumptions/semantics. So here's what
One usage of this concept that justifies this interpretion of my_roi = Slice5D(x=slice(0, 10), y=slice(0, 10))
roi_with_halo = my_roi.enlarged(radius=Point5d(x=5, y=5)) # adds halo,
assert roi_with_halo == Slice5D(x=slice(-5, 15), y=slice(-5, 15)) # roi_with_halo goes out of bounds for a tile on the edge
# my_datasource will decide how to fill in the out-of-bounds roi; reflect, zeros, whatever
data = my_datasource.retrieve(roi_with_halo)
assert data.shape == roi_with_halo == Shape5D(x=20, y=20) |
Maybe a different name should be considered then, something like I'd argue against allowing undefined instances of this thing and rather have e.g.
|
I'm not saying that the current implementation couldn't actually work for what I want to do :). However, I'm reluctant to use it. I'll try to summarize this a bit:
sl1 = Slice5D.zero(x=slice(None))
sl2 = Slice5D.zero(*x=slice(-9999, 9999))
# so
sl1.contains(sl2) == True
# but the data returned by indexing with sl1 will not contain
# the data that is retrieved with indexing with sl2
How to make this more usable for Python developers? A solution, should:
|
Yes. This is supremely convenient for expressing the halos thing. There are no edge cases if we treat negative coordinates as points in space.
Start inclusive, stop exclusive. That's why I was using
What do you mean by "cut off one unit in every direction"? I also don't see an issue with defining a volume/hypervolume/whatever. I do have methods for that, but I could remove them and just let the users multiply whatever axes they are interested in.
You got me there =) This is also something that deserves more thought. I also don't like the fact that the
Also a very good point 👍 It is indeed super weird that
Agreed. I have once considered differentiating slices into something like
Also agree with that.
Why not?. Why wouldn't the shape of
I really like obsessing with type annotations, but there is only so much one can do with those, specially if your types are numbers or some other very fundamental concepts; For example, you're not supposed to index a list with numbers bigger than its length, but there is no reasonable way to express that as a type, nor to statically check it if you did; Similarly, say that I replace all |
Only clarifying where you asked more questions:
this is basically the only property of slice you (can) use. No strides, negative indices have a different meaning, no inf....
The problem is, if I have a region defined by two points, floating point numbers, then this first of all does not imply any natural increment. Furthermore, a rectangle that starts at
but types. It's really number types that are wrong and set the wrong expectations there. What is so bad about a coordinate being |
Shape5D seems to be a shape that has floating point number extents - fine.
to_tuple
will cast those to integers. Also in some other places it looks weird allowing floating point extents. Takeis_scalar
for example. How do you even define this with floats? Is something with ac
extent of 1.9 still scalar?! And what would this even mean in channel dimension...Also think of a shape with integers size along
x=9.0
, is9
included [probing at 9.0 should be possible] (like it would be in a continuous world) or excluded (in the discrete world [probing not possible at this position]).What was your motivation? Were you concerned with world coordinates? Then it might be better to allow for a transformation to world coordinates. Where do you need that?
The text was updated successfully, but these errors were encountered: