Skip to content

Commit

Permalink
fix clang format again
Browse files Browse the repository at this point in the history
  • Loading branch information
nickyfantasy committed Mar 29, 2018
1 parent 5d1b040 commit 3de9514
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
3 changes: 2 additions & 1 deletion visualdl/logic/sdk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ void Audio::SetSample(int index,
CHECK_LE(index, num_records_)
<< "index should be less than or equal to number of records";

BinaryRecord brcd(GenBinaryRecordDir(step_.parent()->dir()), std::string(data.begin(),data.end()));
BinaryRecord brcd(GenBinaryRecordDir(step_.parent()->dir()),
std::string(data.begin(), data.end()));
brcd.tofile();

auto entry = step_.MutableData<std::vector<byte_t>>(index);
Expand Down
6 changes: 4 additions & 2 deletions visualdl/logic/sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ struct Image {
void FinishSampling();

/*
* A combined interface for IndexOfSampleTaken and SetSample, simpler but might be
* A combined interface for IndexOfSampleTaken and SetSample, simpler but
* might be
* low efficiency.
*/
void AddSample(const std::vector<shape_t>& shape,
Expand Down Expand Up @@ -362,7 +363,8 @@ struct Audio {
void FinishSampling();

/*
* A combined interface for IndexOfSampleTaken and SetSample, simpler but might be
* A combined interface for IndexOfSampleTaken and SetSample, simpler but
* might be
* low efficiency.
*/
void AddSample(int sample_rate, const std::vector<value_t>& data);
Expand Down
34 changes: 34 additions & 0 deletions visualdl/logic/sdk_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,40 @@ TEST(Image, add_sample_test) {
CHECK_EQ(image2read.num_records(), num_steps);
}

TEST(Image, add_sample_test) {
const auto dir = "./tmp/sdk_test.image";
LogWriter writer__(dir, 4);
auto writer = writer__.AsMode("train");

auto tablet = writer.AddTablet("image0");
components::Image image(tablet, 3, 1);
const int num_steps = 10;

LOG(INFO) << "write images";
image.SetCaption("this is an image");
for (int step = 0; step < num_steps; step++) {
image.StartSampling();
for (int i = 0; i < 7; i++) {
vector<int64_t> shape({5, 5, 3});
vector<float> data;
for (int j = 0; j < 3 * 5 * 5; j++) {
data.push_back(float(rand()) / RAND_MAX);
}
image.AddSample(shape, data);
}
image.FinishSampling();
}

LOG(INFO) << "read images";
// read it
LogReader reader__(dir);
auto reader = reader__.AsMode("train");
auto tablet2read = reader.tablet("image0");
components::ImageReader image2read("train", tablet2read);
CHECK_EQ(image2read.caption(), "this is an image");
CHECK_EQ(image2read.num_records(), num_steps);
}

TEST(Histogram, AddRecord) {
const auto dir = "./tmp/sdk_test.histogram";
LogWriter writer__(dir, 1);
Expand Down

0 comments on commit 3de9514

Please sign in to comment.