Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix minmax #53

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
not return 1 if input is empty
  • Loading branch information
takenori-y committed Dec 13, 2023
commit 27554d8c7cc7bc00d92464460de8ac3ca8238594
17 changes: 11 additions & 6 deletions src/main/minmax.cc
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ int main(int argc, char* argv[]) {
}
} else if (kFindValueFromVectorSequenceForEachDimension ==
way_to_find_value) {
bool empty(true);
while (sptk::ReadStream(false, 0, 0, vector_length, &data, &input_stream,
NULL)) {
for (int vector_index(0); vector_index < vector_length; ++vector_index) {
Expand All @@ -353,14 +354,18 @@ int main(int argc, char* argv[]) {
sptk::PrintErrorMessage("minmax", error_message);
return 1;
}
if (empty) empty = false;
}
}
if (!WriteMinMaxValues(minmax_accumulation, buffer, num_best, output_format,
output_stream_pointer)) {
std::ostringstream error_message;
error_message << "Failed to write values";
sptk::PrintErrorMessage("minmax", error_message);
return 1;
// Write value if at least one data is given.
if (!empty) {
if (!WriteMinMaxValues(minmax_accumulation, buffer, num_best,
output_format, output_stream_pointer)) {
std::ostringstream error_message;
error_message << "Failed to write values";
sptk::PrintErrorMessage("minmax", error_message);
return 1;
}
}
}

Expand Down