-
Notifications
You must be signed in to change notification settings - Fork 93
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 long[] getDimensions()? #244
Comments
There's: |
@acardona you beat me by 10 seconds... |
Would it be possible to implement it into the Interval base class? For rookies it's impossible to know that entry point for searching for methods.... |
Oh and thanks btw! ;-) |
To be fair, I am equally annoyed by the length of the
.. or some other, shorter yet equally clear alias. |
Possibly we could put it as a default method into the |
I also create images of non-imglib2-types and there I need that long[] array... Thus, I would love to have the getDimensions() default method :-) |
I second that. A |
I actually agree. |
@maarzt Do you have an opinion? |
That'd be great. Actually, a major issue now in imglib2 is lack of discoverability. Teaching novices about |
Perfectly fine with adding this as default implementations into the interfaces. When ImgLib2 was created, default implementations in interfaces did not exist and I wanted to limit the burden of implementing everybody's favorite helper method in a new class as much as possible. Default implementations make this consideration irrelevant. |
Yes, we obviously totally add the The Longer Answer: If you think about the naming of the methods it becomes interesting: For the method Finally the |
@maarzt All good points. Thanks! It might be safe to add On the other hand, then there is a mismatch between |
I vote for the verbose names. Same as now in |
Very good points @maarzt
Agreed. As an addendum, what I like to do in such cases, is to introduce methods like this: long[] min(long[] min);
int[] min(int[] min);
<P extends Positionable> P min(P min); Unfortunately, this would change the return types of these methods. Whether or not this is a breaking change is discussed here, in particular this answer that says: Unfortunately, yes, changing a void method to return something is a breaking change. |
Ok, great, let's go with the verbose method names then! Anybody wants to make a PR? @hanslovsky I would also be happy with long[] min(long[] min);
int[] min(int[] min);
<P extends Positionable> P min(P min); It's definitely a breaking change. It will not only require adaption of the implementations of these methods in downstream projects. These adaptions are trivial, but still, it could be lot of places... If you ant to tackle this, you could make this a (separate) PR and we collect a few of those for next time we break API... |
Not in the near future, unfortunately, pretty busy right now. But I might get back to it sometime around fall this year. |
Has this happened yet? |
This issue has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/useful-or-interesting-functions-for-imglib2-tests-and-examples/40703/7 |
@axtimwalde and I just finished a PR that adds
|
@haesleinhuepf Please teach your students that using these methods frequently (e.g. per pixel) will make their code slow and sluggish because they create objects on the heap. Encourage them to use the previously existing in-place variants instead. |
Good point, @axtimwalde. In fact I'm using this most often to create images of given size in tests and when talking to GPUs (See my initial example). Thanks anyway, that hint makes a lot of sense. Also thanks @bogovicj and others involved for making this happen 🙂 |
Dear *,
assume, I would like to make a copy or convert some RAI, I'm very often typing this:
Might it be possible to implement a getDimensions() method somewhere to allow writing this shorter?
Or is there an alternate way of doing this?
Thanks!
Cheers,
Robert
The text was updated successfully, but these errors were encountered: