[mlpack-git] master: fix bugs--may read invalid stream (5d964a1)
gitdub at mlpack.org
gitdub at mlpack.org
Tue May 31 11:49:17 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/2629a4fd65684e2bd4544d5ef8ea07fa9ad594a7...ee95e2030ddd526368e377b4e1c13484d471e307
>---------------------------------------------------------------
commit 5d964a1633faddeaf152b9495d96a271bb455a91
Author: stereomatchingkiss <stereomatchingkiss at gmail.com>
Date: Tue May 31 23:49:14 2016 +0800
fix bugs--may read invalid stream
>---------------------------------------------------------------
5d964a1633faddeaf152b9495d96a271bb455a91
src/mlpack/core/data/load_impl.hpp | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/mlpack/core/data/load_impl.hpp b/src/mlpack/core/data/load_impl.hpp
index c934181..90d6d37 100644
--- a/src/mlpack/core/data/load_impl.hpp
+++ b/src/mlpack/core/data/load_impl.hpp
@@ -459,14 +459,19 @@ bool Load(const std::string& filename,
if(transpose)
{
std::vector<std::vector<std::string>> tokensArray;
+ std::vector<std::string> tokens;
while (!stream.bad() && !stream.fail() && !stream.eof())
{
// Extract line by line.
std::getline(stream, buffer, '\n');
Tokenizer lineTok(buffer, sep);
- tokensArray.emplace_back(details::ToTokens(lineTok));
+ tokens = details::ToTokens(lineTok);
+ if(tokens.size() == cols)
+ {
+ tokensArray.emplace_back(details::ToTokens(lineTok));
+ }
}
- std::vector<std::string> tokens;
+ std::cout<<"array size : "<<tokensArray.size()<<std::endl;
for(size_t i = 0; i != cols; ++i)
{
details::TransPoseTokens(tokensArray, tokens, i);
More information about the mlpack-git
mailing list