fixed sign type mismatch warnings in cnpy

pull/265/head
Vitaliy Lyudvichenko 10 years ago
parent 75e09fdc63
commit b9e85edd39
  1. 4
      modules/dnn/test/cnpy.cpp
  2. 6
      modules/dnn/test/cnpy.h

@ -65,7 +65,7 @@ void cnpy::parse_npy_header(FILE* fp, unsigned int& word_size, unsigned int*& sh
std::string header = fgets(buffer,256,fp); std::string header = fgets(buffer,256,fp);
assert(header[header.size()-1] == '\n'); assert(header[header.size()-1] == '\n');
int loc1, loc2; size_t loc1, loc2;
//fortran order //fortran order
loc1 = header.find("fortran_order")+16; loc1 = header.find("fortran_order")+16;
@ -76,7 +76,7 @@ void cnpy::parse_npy_header(FILE* fp, unsigned int& word_size, unsigned int*& sh
loc2 = header.find(")"); loc2 = header.find(")");
std::string str_shape = header.substr(loc1+1,loc2-loc1-1); std::string str_shape = header.substr(loc1+1,loc2-loc1-1);
if(str_shape[str_shape.size()-1] == ',') ndims = 1; if(str_shape[str_shape.size()-1] == ',') ndims = 1;
else ndims = std::count(str_shape.begin(),str_shape.end(),',')+1; else ndims = (unsigned)std::count(str_shape.begin(),str_shape.end(),',')+1;
shape = new unsigned int[ndims]; shape = new unsigned int[ndims];
for(unsigned int i = 0;i < ndims;i++) { for(unsigned int i = 0;i < ndims;i++) {
loc1 = str_shape.find(","); loc1 = str_shape.find(",");

@ -87,7 +87,7 @@ namespace cnpy {
assert(tmp_dims == ndims); assert(tmp_dims == ndims);
} }
for(int i = 1; i < ndims; i++) { for(unsigned i = 1; i < ndims; i++) {
if(shape[i] != tmp_shape[i]) { if(shape[i] != tmp_shape[i]) {
std::cout<<"libnpy error: npy_save attempting to append misshaped data to "<<fname<<"\n"; std::cout<<"libnpy error: npy_save attempting to append misshaped data to "<<fname<<"\n";
assert(shape[i] == tmp_shape[i]); assert(shape[i] == tmp_shape[i]);
@ -109,7 +109,7 @@ namespace cnpy {
} }
unsigned int nels = 1; unsigned int nels = 1;
for(int i = 0;i < ndims;i++) nels *= shape[i]; for(unsigned i = 0;i < ndims;i++) nels *= shape[i];
fwrite(data,sizeof(T),nels,fp); fwrite(data,sizeof(T),nels,fp);
fclose(fp); fclose(fp);
@ -219,7 +219,7 @@ namespace cnpy {
dict += tostring(sizeof(T)); dict += tostring(sizeof(T));
dict += "', 'fortran_order': False, 'shape': ("; dict += "', 'fortran_order': False, 'shape': (";
dict += tostring(shape[0]); dict += tostring(shape[0]);
for(int i = 1;i < ndims;i++) { for(unsigned i = 1;i < ndims;i++) {
dict += ", "; dict += ", ";
dict += tostring(shape[i]); dict += tostring(shape[i]);
} }

Loading…
Cancel
Save