-
Notifications
You must be signed in to change notification settings - Fork 55
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
Towards consistent style, part 1: a naming guide #229
Comments
Should all functions that are only meant to support higher level API begin with an underscore? |
Should |
|
When dealing with Mathematical Morphology operations we could define abstract type MorphologicalOperation end
struct Erosion <: MorphologicalOperation end
struct Dilation <: MorphologicalOperation end
struct Opening <: MorphologicalOperation end
struct Closing <: MorphologicalOperation end
struct BottomHat <: MorphologicalOperation end
struct TopHat <: MorphologicalOperation end
struct Laplacian <: MorphologicalOperation end
struct HitAndMiss <: MorphologicalOperation end and then dispatch on This is analogous to what we are starting to do with our histogram operations, i.e. |
Worth pointing out that most people seem to prefer |
I would count myself among the group that would prefer |
As a quick note, I don't mean to vote for Drawbacks of "start with a verb" convention:
good point of
Is there any reference saying that we must use the "start with a verb" convention? Python packages uses the package name as the prefix to TAB (e.g., But for Julia we don't necessarily do I think A list of names with
one reason for not using |
Which names should be taken? add noise to an image:
update the image tracker status:
|
I think that So as general convention when we have a function with Just an idea, please guide me if I'm going wrong. |
Can you explain this? what are |
For example :
I think I got it wrong, the agrument order for consistent reading depends more on the function name rather than |
My understanding is:
They're quite different here. Hypothetically, if there're many methods applying noise:
all these examples still follow the where-what-how pattern |
Ok, I got what you are trying to say. |
yes, I have to admit that But this case is quite special in the sense that we can support in-place modification, i.e., Considering the existence of in-place modification methods, we might not follow the |
Recent ideas about a shared functions API may be worth considering for solidifying naming (brought up here and most recently implemented here. Pros:
Cons:
|
Isn't that focused on how you handle the problem of several different frameworks needing to collaborate? AFAICT JuliaImages is the one-and-only contender for native image processing in Julia, though I could be wrong. Or were there naming guidelines in that thread? (Sorry, I just looked at the link, the thread as a whole is very long.) |
I believe the original motivation was something with JuliaData and JuliaStats sharing a lot of functions, but the actual problem being addressed is any sort of shared function naming between packages. We already have this in a lot of ways in ImageCore, ImageMetadata, and ImageAxes. It would seem a lot "cleaner" to have one package that implements these and is the focus of API discussions. Perhaps the easiest way is to just move a couple things over to ImageCore and make it the central hub for all API. However, I think the ability to work with non-image focused communities is what makes this idea most appealing. Specifically, I would love it if there was a common interface between ImageFiltering and NNlib (kind of like Flux's version of ImageFiltering). A lot of work has gone into both and I think this may be an easy start to introducing compatibility between the two. I'm sure there are other similar situations to this that would be beneficial to multiple communities. |
One use case: I was keeping thinking of the possibilities of including/incorporating deep learning related methods into/with JuliaImages. We can hold something like |
To my thinking, that's basically what ImageCore is. It provides a lot of stub traits that then get fleshed out by ImageAxes and ImageMetadata. Of course it also provides |
Some further explanation. I think it's quite different from the purpose of I can imagine a set of APIs such as enhance!(::GenericImage, ::Algorithm [, ::ComputingResource])
enhance([::Type, ] ::GenericImage, ::Algorithm [, ::ComputingResource])
restore!(::GenericImage, ::Algorithm [, ::ComputingResource])
restore([::Type, ] ::GenericImage, ::Algorithm [, ::ComputingResource])
binarize!(::GenericImage, ::BinarizationAlgorithm [, ::ComputingResource])
binarize([::Type, ] ::GenericImage, ::BinarizationAlgorithm [, ::ComputingResource])
denoise!(::GenericImage, ::NoiseReductionAlgorithm [, ::ComputingResource])
denoise([::Type, ] ::GenericImage, ::NoiseReductionAlgorithm [, ::ComputingResource]) Assume there are Another promising feature here is both |
I think the stub traits would make the bulk of what would go in something like I'm not as concerned about the amount of functionality in one package as much as I am about simplifying interoperability with other ecosystems and easing maintenance. I mention the use of NNlib because I think it's a good example of where a package may not want to even depend on ImageCore but it would be mutually beneficial to share an API. |
@johnnychen94 , thanks for providing those examples. That's pretty much what I was thinking of. Although, I think there are cases where we could make it as simple as function binarize! end |
Yes, ImageCore is essentially limited to traits, and deliberately avoids algorithms. If there is need for "sharing" algorithms across many packages, that sounds reasonable. |
@timholy can you create such a repository under JuliaImages as an experimental place to see how this idea works in general? And we can move the detailed discussions there. But I think we need further and comprehensive thoughts before starting this work. |
Would it be worth discussing how/if we should implement the BlueStyle in JuliaImages? I'd personally rather use something that others have already actively discussed and implemented than reinventing everything. |
Since currently there aren't many contributors in JuliaImages. I think the focus of this issue is more on names as a part of APIs of JuliaImages.jl, instead of coding styles. For me, package-wise consistency would be acceptable. |
Also removes code in exposure.jl which is now found in the ImageContrastAdjustment.jl package.
Replying to https://github.com/JuliaImages/Images.jl/issues/767#issuecomment-475911504, which was posted at around the time I was wrapping up my work on the debugger and therefore not paying much attention.
I think that's OK. Ideally they'd be consistent in what they do, and we can always scope by module.
I don't like adding
That's the best thing about it. But since we have color types to indicate "this is an image," the line between arrays and images is otherwise blurry (and should be). The flip side of your argument is to look at how many people avoid using ImageFiltering just because of the "image" part of the name.
There's no must about it, but see:
Also linking JuliaLang/julia#20402 as one of the best "cleanup" issues I know of. Finally, if you just do for n in names(Base)
println(n)
end I think you'll be impressed at what a large fraction of operations that compute something use a verb for their name. (Again, I'm not proposing a verb for everything, I'm saying it makes sense specifically for operations that compute something .)
As you probably know by now, that works in Julia too.
I think the |
I finally took some time to really evaluate my original comment concerning consistency with methods that refer to axes in some way. I've put together a small table with some proposed changes. The proposed changes are motivated by:
Where
There are some other relevant methods (like Edit: I may be over analyzing this at the risk of just making unhelpful breaking changes. Just down vote if this is totally off base. |
I've thrown together some of this here https://github.com/Tokazama/NamedIndicesMeta.jl in case people are interested. If people like the idea then I can polish it up and make a PR for the image related stuff. |
Rename `psnr` and `ssim` to `assess_psnr` and `assess_ssim` according the general guideline [1]: > for functions that compute something or perform an operation, start with a verb References: [1] https://github.com/JuliaImages/Images.jl/issues/767 [2] scikit-images also use similar names: `compare_psnr` and `compare_ssim`
* rename psnr and ssim Rename `psnr` and `ssim` to `assess_psnr` and `assess_ssim` according the general guideline [1]: > for functions that compute something or perform an operation, start with a verb References: [1] https://github.com/JuliaImages/Images.jl/issues/767 [2] scikit-images also use similar names: `compare_psnr` and `compare_ssim` * ImageQualityIndexes v0.1.4
JuliaImages has grown over several years through the efforts of many people; now that Julia is itself stable, I anticipate new waves of growth in the coming years. To help ensure its health and vibrancy, I think we need to establish some guidelines that will help give such a large, distributed project a unified feel. To me, step 1 of this process is to develop a naming guide and to rename some of our functions or objects accordingly. The sooner we do this the better.
A naming guide should not be arbitrary, but be based on principles. I propose we use this issue to hash out the principles. Here are a few thoughts to get the discussion rolling:
HOG()
)colorview
)axes
,eltype
)warp
)mappedarray
rather thanmaparray
)More examples of current names that are consistent with these guidelines:
testimage
,line
are fine as-is (by the "constructors are nouns" convention)colorview
as a lazy computation is better than an alternative likecombinechannels
build_histogram
andadjust_histogram
(implemented in Addsbuild_histogram(Equalization(),...)
Images.jl#761, Addsadjust_histogram(Equalization(),...)
Images.jl#762) are better thanimhist
andhisteq
(which, for now, still remain)Some examples of current names that would change due to these guidelines:
imfilter
violates the "start with a verb" convention.filterarray
,mapstencil
(inspired bymapwindow
) would both be acceptableimshow
->showimage
dilate
is good,tophat
seems wrong, though I don't immediately have a suggestion as to how to change itThe text was updated successfully, but these errors were encountered: