-
Notifications
You must be signed in to change notification settings - Fork 15
Close #152 Represent Bools as Enums #153
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,8 @@ using namespace splash; | |
|
||
SimpleDataTest::SimpleDataTest() : | ||
ctUInt32(), | ||
ctUInt64() | ||
ctUInt64(), | ||
ctBool() | ||
{ | ||
dataCollector = new SerialDataCollector(10); | ||
srand(time(NULL)); | ||
|
@@ -74,9 +75,13 @@ bool SimpleDataTest::subtestWriteRead(Dimensions gridSize, Dimensions borderSize | |
// initial part of the test: data is written to the file, once with and once | ||
// without borders | ||
uint64_t *dataWrite = new uint64_t[bufferSize]; | ||
bool *boolWrite = new bool[bufferSize]; | ||
|
||
for (uint64_t i = 0; i < bufferSize; i++) | ||
{ | ||
dataWrite[i] = i; | ||
boolWrite[i] = ( i%2 == 0 ); | ||
} | ||
|
||
dataCollector->write(10, ctUInt64, dimensions, Selection(gridSize), "deep/folders/data", dataWrite); | ||
datasetNames.insert("deep/folders/data"); | ||
|
@@ -85,6 +90,13 @@ bool SimpleDataTest::subtestWriteRead(Dimensions gridSize, Dimensions borderSize | |
borderSize), "deep/folders/data_without_borders", dataWrite); | ||
datasetNames.insert("deep/folders/data_without_borders"); | ||
|
||
dataCollector->write(10, ctBool, dimensions, Selection(gridSize), "deep/folders/data_bool", boolWrite); | ||
datasetNames.insert("deep/folders/data_bool"); | ||
|
||
dataCollector->write(20, ctBool, dimensions, Selection(gridSize, smallGridSize, | ||
borderSize), "deep/folders/data_bool_without_borders", boolWrite); | ||
datasetNames.insert("deep/folders/data_bool_without_borders"); | ||
|
||
dataCollector->close(); | ||
|
||
// first part of the test: read data with borders to a cleared | ||
|
@@ -103,14 +115,17 @@ bool SimpleDataTest::subtestWriteRead(Dimensions gridSize, Dimensions borderSize | |
int32_t *ids = NULL; | ||
size_t numIDs = 0; | ||
dataCollector->getEntryIDs(NULL, &numIDs); | ||
#if defined TESTS_DEBUG | ||
printf("number of entry IDs=%d\n", numIDs); | ||
#endif | ||
CPPUNIT_ASSERT(numIDs == 2); | ||
ids = new int32_t[numIDs]; | ||
dataCollector->getEntryIDs(ids, NULL); | ||
|
||
for (uint32_t j = 0; j < numIDs; ++j) | ||
{ | ||
dataCollector->getEntriesForID(ids[j], NULL, &numEntries); | ||
CPPUNIT_ASSERT(numEntries == 1); | ||
CPPUNIT_ASSERT(numEntries == 2); | ||
entries = new DataCollector::DCEntry[numEntries]; | ||
dataCollector->getEntriesForID(ids[j], entries, NULL); | ||
|
||
|
@@ -129,26 +144,44 @@ bool SimpleDataTest::subtestWriteRead(Dimensions gridSize, Dimensions borderSize | |
delete[] ids; | ||
|
||
uint64_t *dataRead = new uint64_t[bufferSize]; | ||
bool *boolRead = new bool[bufferSize]; | ||
for (uint64_t i = 0; i < bufferSize; i++) | ||
{ | ||
dataRead[i] = UINT64_MAX; | ||
boolRead[i] = false; | ||
} | ||
|
||
Dimensions resultSize; | ||
dataCollector->read(10, "deep/folders/data", resultSize, dataRead); | ||
|
||
for (uint32_t i = 0; i < 3; i++) | ||
CPPUNIT_ASSERT(resultSize[i] == gridSize[i]); | ||
|
||
dataCollector->read(10, "deep/folders/data_bool", resultSize, boolRead); | ||
|
||
for (uint64_t i = 0; i < bufferSize; i++) | ||
{ | ||
if (dataRead[i] != dataWrite[i]) | ||
{ | ||
#if defined TESTS_DEBUG | ||
std::cout << i << ": " << dataRead[i] << " != exptected " << dataWrite[i] << std::endl; | ||
std::cout << i << ": " << dataRead[i] << " != expected " << dataWrite[i] << std::endl; | ||
#endif | ||
resultsCorrect = false; | ||
break; | ||
} | ||
if (boolRead[i] != boolWrite[i]) | ||
{ | ||
#if defined TESTS_DEBUG | ||
std::cout << i << ": " << boolRead[i] << " != expected " << boolWrite[i] << std::endl; | ||
#endif | ||
resultsCorrect = false; | ||
break; | ||
} | ||
} | ||
|
||
delete[] dataRead; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. delete boolRead here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done, thx! |
||
delete[] boolRead; | ||
delete[] boolWrite; | ||
|
||
CPPUNIT_ASSERT_MESSAGE("simple write/read failed", resultsCorrect); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,8 +34,8 @@ class SimpleDataTest : public CPPUNIT_NS::TestFixture | |
{ | ||
CPPUNIT_TEST_SUITE(SimpleDataTest); | ||
|
||
CPPUNIT_TEST(testWriteRead); | ||
CPPUNIT_TEST(testNullWrite); | ||
CPPUNIT_TEST(testWriteRead); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason for that change? :) I liked my order There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I want to read the data later on via h5py :) |
||
|
||
CPPUNIT_TEST_SUITE_END(); | ||
|
||
|
@@ -63,6 +63,7 @@ class SimpleDataTest : public CPPUNIT_NS::TestFixture | |
|
||
ColTypeUInt32 ctUInt32; | ||
ColTypeUInt64 ctUInt64; | ||
ColTypeBool ctBool; | ||
DataCollector *dataCollector; | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Copyright 2015 Axel Huebl | ||
# | ||
# This file is part of libSplash. | ||
# | ||
# libSplash is free software: you can redistribute it and/or modify | ||
# it under the terms of of either the GNU General Public License or | ||
# the GNU Lesser General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# libSplash is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License and the GNU Lesser General Public License | ||
# for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# and the GNU Lesser General Public License along with libSplash. | ||
# If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
|
||
import h5py | ||
import numpy as np | ||
|
||
f = h5py.File("h5/testWriteRead_0_0_0.h5", "r") | ||
data = f["data/10/deep/folders/data_bool"] | ||
|
||
len = data.size | ||
data1d = data[:,:,:].reshape(len) | ||
|
||
for i in np.arange(len): | ||
val = ( i%2 == 0 ); | ||
if data1d[i] != val: | ||
exit(1) | ||
|
||
exit(0) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ function testMPI() | |
} | ||
|
||
testSerial ./SimpleDataTest.cpp.out "Testing simple data read/write..." | ||
testSerial ./readBool.py "Testing h5py compatible read..." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to check if python is available and run the readBool.py only in that case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, the same is true for the There are actually some issues for the upcoming 1.3 release that will take care of that. |
||
|
||
testSerial ./AttributesTest.cpp.out "Testing reading/writing attributes..." | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same 1byte memory footprint as before, but now an 8-bit native (short) int: link