Skip to content

Commit

Permalink
add tests for both array and field style numpy data
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed Mar 30, 2018
1 parent eaee9a1 commit 29a8903
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions plugins/python/test/NumpyReaderTest.cpp
Expand Up @@ -57,12 +57,11 @@ class NumpyReaderTest : public ::testing::Test

};

TEST_F(NumpyReaderTest, NumpyReaderTest_read)
TEST_F(NumpyReaderTest, NumpyReaderTest_read_fields)
{
StageFactory f;

Options ops;
// Support::temppath("mylog_three.txt"),
ops.add("filename", Support::datapath("plang/1.2-with-color.npy"));

NumpyReader reader;
Expand All @@ -71,11 +70,40 @@ TEST_F(NumpyReaderTest, NumpyReaderTest_read)
PointTable table;

reader.prepare(table);
reader.log()->setLevel(LogLevel::Debug1);
PointViewSet viewSet = reader.execute(table);
EXPECT_EQ(viewSet.size(), 1u);
PointViewPtr view = *viewSet.begin();
EXPECT_EQ(view->size(), 1065u);
EXPECT_EQ(view->layout()->pointSize(), 34u);

EXPECT_EQ(view->getFieldAs<int16_t>(pdal::Dimension::Id::Intensity,800), 49);
EXPECT_EQ(view->getFieldAs<int32_t>(pdal::Dimension::Id::X,400), 63679039);

}


TEST_F(NumpyReaderTest, NumpyReaderTest_read_array)
{
StageFactory f;

Options ops;
ops.add("filename", Support::datapath("plang/perlin.npy"));

NumpyReader reader;
reader.setOptions(ops);

PointTable table;

reader.prepare(table);

// reader.log()->setLevel(LogLevel::Debug1);
PointViewSet viewSet = reader.execute(table);
PointViewPtr view = *viewSet.begin();
EXPECT_EQ(view->size(), 10000u);
EXPECT_EQ(view->layout()->pointSize(), 16u);

EXPECT_EQ(view->getFieldAs<double>(pdal::Dimension::Id::Intensity,5000), 0.5);
EXPECT_EQ(view->getFieldAs<uint32_t>(pdal::Dimension::Id::X,5000), 51u);

}

Binary file added test/data/plang/perlin.npy
Binary file not shown.

0 comments on commit 29a8903

Please sign in to comment.