Skip to content

Commit 783fa7d

Browse files
TLipedemcabbott
andauthored
Make error messaging for unexpected values simpler
Co-authored-by: Michael Abbott <32575566+mcabbott@users.noreply.github.com>
1 parent 6ad6e97 commit 783fa7d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/onehot.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,9 @@ onehotbatch(data, labels, default...) = _onehotbatch(data, length(labels) < 32 ?
188188
function _onehotbatch(data, labels)
189189
indices = UInt32[something(_findval(i, labels), 0) for i in data]
190190
if 0 in indices
191-
unexpected_values = unique(data[indices .== 0])
192-
error("Values $unexpected_values are not in labels")
191+
for x in data
192+
isnothing(_findval(x, labels)) && error("Value $x not found in labels")
193+
end
193194
end
194195
return OneHotArray(indices, length(labels))
195196
end

0 commit comments

Comments
 (0)