93
93
# helper function for data manipulation
94
94
function munge_data (u:: AbstractVector , t:: AbstractVector ;
95
95
check_sorted = t, sorted_arg_name = (" second" , " t" ))
96
+ length (t) == length (u) ||
97
+ throw (ArgumentError (" `u`, `t` length mismatch: length(t) ≠ length(u)" ))
98
+
96
99
Tu = nonmissingtype (eltype (u))
97
100
Tt = nonmissingtype (eltype (t))
98
101
@@ -109,8 +112,6 @@ function munge_data(u::AbstractVector, t::AbstractVector;
109
112
return u, t
110
113
end
111
114
112
- @assert length (t) == length (u)
113
-
114
115
non_missing_mask = map ((ui, ti) -> ! ismissing (ui) && ! ismissing (ti), u, t)
115
116
u = convert (AbstractVector{Tu}, u[non_missing_mask])
116
117
t = convert (AbstractVector{Tt}, t[non_missing_mask])
@@ -119,13 +120,15 @@ function munge_data(u::AbstractVector, t::AbstractVector;
119
120
end
120
121
121
122
function munge_data (U:: AbstractMatrix , t:: AbstractVector )
123
+ length (t) == size (U, 2 ) ||
124
+ throw (ArgumentError (" `u`, `t` length mismatch: length(t) ≠ size(U, 2)" ))
125
+
122
126
TU = nonmissingtype (eltype (U))
123
127
Tt = nonmissingtype (eltype (t))
124
128
if TU === eltype (U) && Tt === eltype (t)
125
129
return U, t
126
130
end
127
131
128
- @assert length (t) == size (U, 2 )
129
132
non_missing_mask = map (
130
133
(uis, ti) -> ! any (ismissing, uis) && ! ismissing (ti), eachcol (U), t)
131
134
U = convert (AbstractMatrix{TU}, U[:, non_missing_mask])
@@ -135,13 +138,15 @@ function munge_data(U::AbstractMatrix, t::AbstractVector)
135
138
end
136
139
137
140
function munge_data (U:: AbstractArray{T, N} , t) where {T, N}
141
+ length (t) == size (U, N) ||
142
+ throw (ArgumentError (" `u`, `t` length mismatch: length(t) ≠ size(U, N)" ))
143
+
138
144
TU = nonmissingtype (eltype (U))
139
145
Tt = nonmissingtype (eltype (t))
140
146
if TU === eltype (U) && Tt === eltype (t)
141
147
return U, t
142
148
end
143
149
144
- @assert length (t) == size (U, N)
145
150
non_missing_mask = map (
146
151
(uis, ti) -> ! any (ismissing, uis) && ! ismissing (ti), eachslice (U; dims = N), t)
147
152
U = convert (AbstractArray{TU, N}, copy (selectdim (U, N, non_missing_mask)))
0 commit comments