-
Notifications
You must be signed in to change notification settings - Fork 21
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
add GenericImage and GenericRGBImage alias #80
Conversation
* PixelLike * GenericImage * GenericRGBImage * RGB2dImage
Codecov Report
@@ Coverage Diff @@
## master #80 +/- ##
=======================================
Coverage 66.17% 66.17%
=======================================
Files 9 9
Lines 408 408
=======================================
Hits 270 270
Misses 138 138
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #80 +/- ##
=======================================
Coverage 66.17% 66.17%
=======================================
Files 9 9
Lines 408 408
=======================================
Hits 270 270
Misses 138 138
Continue to review full report at Codecov.
|
I'm a little bothered by an explosion of names that do not yet have obvious value. Perhaps some illustrations showing what they make better? |
These three seems quite redundant according to my use experiences const RealLike{T<:Real} = NumberLike{T}
const FloatLike{T<:AbstractFloat} = RealLike{T}
const FractionalLike{T<:Union{FixedPoint, AbstractFloat}} = RealLike{T} They appear to be some kind of short alias in the beginning, for example, in ImageDistances function colwise(dist::PreMetric,
a::AbstractMatrix{<:GenericImage},
b::AbstractMatrix{<:GenericImage})
n = get_common_ncols(a, b)
r = Vector{result_type(dist, a, b)}(undef, n)
colwise!(r, dist, a, b)
end This annotation is more readable than colwise(dist::PreMetric,
a::AbstractMatrix{<:AbstractArray{Union{<:Colorant, <:Number}}},
b::AbstractMatrix{<:AbstractArray{Union{<:Colorant, <:Number}}}) Another advantage I didn't check yet, is to provide a similar power of traits. Hypothetically speaking, # ImageMesh.jl
struct Pixel{T<:Point, CT<:Colorant}
pos::T
value::CT
end
# AnotherPackage.jl
using ImageCore
using ImageMesh
const GenericImage = Union{ImageCore.GenericImage, AbstractArray{<:Pixel}}
foo(img::GenericImage) # extend the GenericImage However, I'm not very certain of it. |
That's perhaps the point: why add types that are not actually necessary for anything? The complexity of a project is not entirely independent of
I see value in these: const NumberLike = Union{Number,AbstractGray}
const Pixel = Union{Number,Colorant}
const GenericGrayImage{T<:NumberLike,N} = AbstractArray{T,N}
const GenericImage{T<:Pixel,N} = AbstractArray{T,N} I just don't understand why we can't stop there. (I can also live with In general I'd add new names on a need-to-have basis. |
This solves the conceptual issue: ```julia julia> Colorant <: Pixel false julia> Colorant <: Pixel{T} where T true julia> Colorant{<:FixedPoint} <: Pixel true julia> AbstractGray <: NumberLike false julia> AbstractGray <: NumberLike{T} where T true julia> AbstractGray{<:FixedPoint} <: NumberLike true ```
The previous one dispatches on storage type(e.g., N0f8, Float32) instead of colorant type(e.g., RGB, Gray) Dispatches on storage type is not very useful in practice, so I changed it. Also rewrite the dispatch test cases
Cont. #76
GenericImage
is more general thanAbstractArray{<:Colorant}
, the latter doesn't catchAbstractArray{<:Number}