[shark] 04/24: fixed a broken check that a HDF5 file was opened correctly. Also fixed the buildscript to copy the test files in the build directory. fixes #22

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Dec 10 19:50:03 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/sid
in repository shark.

commit a36fb32ca960492e71a187662ef60ae6f3f2752d
Author: Oswin <oswin.krause at di.ku.dk>
Date:   Tue Dec 1 10:20:10 2015 +0100

    fixed a broken check that a HDF5 file was opened correctly. Also fixed the buildscript to copy the test files in the build directory. fixes #22
---
 Test/CMakeLists.txt       |  6 +-----
 Test/Data/HDF5Tests.cpp   |  7 +++++--
 include/shark/Data/HDF5.h | 10 +++++++---
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/Test/CMakeLists.txt b/Test/CMakeLists.txt
index 83a648e..b7a1193 100644
--- a/Test/CMakeLists.txt
+++ b/Test/CMakeLists.txt
@@ -261,11 +261,7 @@ shark_add_test( RBM/ExactGradientTraining.cpp RBM_ExactGradientTraining)
 
 # Copy test file
 if(HDF5_FOUND)
-	add_custom_command(
-	    TARGET Data_HDF5
-	    POST_BUILD
-	    COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/Test/test_data
-	    COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Test/test_data ${CMAKE_BINARY_DIR}/Test/test_data)	
+	file( COPY test_data/ DESTINATION test_data/ )
 endif()
 
 # Create output dir
diff --git a/Test/Data/HDF5Tests.cpp b/Test/Data/HDF5Tests.cpp
index 8a8d73c..ab46bb7 100644
--- a/Test/Data/HDF5Tests.cpp
+++ b/Test/Data/HDF5Tests.cpp
@@ -16,7 +16,7 @@ class HDF5Fixture
 public:
 	HDF5Fixture()
 	:
-		m_exampleFileName("./test_data/testfile_for_import.h5"),
+		m_exampleFileName("./Test/test_data/testfile_for_import.h5"),
 		m_datasetNameData1("data/data1"),
 		m_labelNameLabel1("data/label1"),
 		m_labelNameWrongLabel("data/wrong_label"),
@@ -108,7 +108,10 @@ boost::test_tools::predicate_result HDF5Fixture::verify(
 
 bool HDF5Fixture::validate(const std::string& msg, const shark::Exception& exp)
 {
-	return exp.what() == msg;
+	bool result = exp.what() == msg;
+	if(! result)
+		std::cout<<"expected: "<<msg<<" got: "<<exp.what()<<std::endl;
+	return result;
 }
 
 BOOST_FIXTURE_TEST_SUITE (Data_HDF5Tests, HDF5Fixture)
diff --git a/include/shark/Data/HDF5.h b/include/shark/Data/HDF5.h
index 6396617..471c940 100644
--- a/include/shark/Data/HDF5.h
+++ b/include/shark/Data/HDF5.h
@@ -137,10 +137,14 @@ void loadIntoMatrix(MatrixType& data, const std::string& fileName, const std::st
 	const size_t MAX_DIMENSIONS = 64u;
 
 	// Open the file, and then get dimension
+	hid_t open = H5Fopen(fileName.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
+	if(open < 0)
+		throw SHARKEXCEPTION((boost::format("[loadIntoMatrix] open file name: %1% (FAILED)") % fileName).str());
+	
 	const ScopedHandle<hid_t> fileId(
-		H5Fopen(fileName.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT),
-		H5Fclose,
-		(boost::format("[loadIntoMatrix] open file name: %1%") % fileName).str());
+		open,
+		H5Fclose
+	);
 
 	boost::array<hsize_t, MAX_DIMENSIONS> dims;
 	dims.assign(0);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/shark.git



More information about the debian-science-commits mailing list