@@ -44,13 +44,13 @@ A warning is issued if missing values are encountered, unless
44
44
See also [`scitype`](@ref), [`scitype_union`](@ref).
45
45
46
46
"""
47
- function coerce (y:: AbstractVector{<:Union{Missing,AbstractFloat}} , T:: Type{Continuous} ;
47
+ function coerce (y:: AbstractVector{<:Union{Missing,AbstractFloat}} , T:: Type{<:Union{Missing, Continuous} } ;
48
48
verbosity= 1 )
49
49
eltype (y) >: Missing && verbosity > 0 && _coerce_missing_warn (T)
50
50
return y
51
51
end
52
52
53
- function coerce (y:: AbstractVector{<:Union{Missing,Real}} , T:: Type{Continuous} ; verbosity= 1 )
53
+ function coerce (y:: AbstractVector{<:Union{Missing,Real}} , T:: Type{<:Union{Missing, Continuous} } ; verbosity= 1 )
54
54
eltype (y) >: Missing && verbosity > 0 && _coerce_missing_warn (T)
55
55
return float (y)
56
56
end
61
61
# as a String, it will error.
62
62
# - if at one point it encounters a Char it will **not** error but return a float
63
63
# corresponding to the Char (e.g. 65.0 for 'A') whence the warning
64
- function coerce (y:: AbstractVector , T:: Type{Continuous} ; verbosity= 1 )
64
+ function coerce (y:: AbstractVector , T:: Type{<:Union{Missing, Continuous} } ; verbosity= 1 )
65
65
has_missings = findfirst (ismissing, y) != = nothing
66
66
has_missings && verbosity > 0 && _coerce_missing_warn (T)
67
67
has_chars = findfirst (e-> isa (e,Char), y) != = nothing
@@ -78,20 +78,20 @@ _int(x::Integer) = x
78
78
_int (x) = Int (x) # may throw InexactError
79
79
80
80
# no-op case
81
- function coerce (y:: AbstractVector{<:Union{Missing,Integer}} , T:: Type{Count} ; verbosity= 1 )
81
+ function coerce (y:: AbstractVector{<:Union{Missing,Integer}} , T:: Type{<:Union{Missing, Count} } ; verbosity= 1 )
82
82
eltype (y) >: Missing && verbosity > 0 && _coerce_missing_warn (T)
83
83
return y
84
84
end
85
85
86
86
# NOTE: this will error if it encounters things like 1.5 or 1//2 (InexactError)
87
- function coerce (y:: AbstractVector{<:Union{Missing,Real}} , T:: Type{Count} ; verbosity= 1 )
87
+ function coerce (y:: AbstractVector{<:Union{Missing,Real}} , T:: Type{<:Union{Missing, Count} } ; verbosity= 1 )
88
88
eltype (y) >: Missing && verbosity > 0 && _coerce_missing_warn (T)
89
89
return _int .(y)
90
90
end
91
91
92
92
# NOTE: case where the data may have been badly encoded and resulted in an Any[] vector
93
93
# a user should proceed with caution here (see comment earlier)
94
- function coerce (y:: AbstractVector , T:: Type{Count} ; verbosity= 1 )
94
+ function coerce (y:: AbstractVector , T:: Type{<:Union{Missing, Count} } ; verbosity= 1 )
95
95
has_missings = findfirst (ismissing, y) != = nothing
96
96
has_missings && verbosity > 0 && _coerce_missing_warn (T)
97
97
has_chars = findfirst (e-> isa (e,Char), y) != = nothing
0 commit comments