-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'developer' into feature/github-ci2
Showing
13 changed files
with
143 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import numpy as np | ||
|
||
|
||
arr = np.arange(10, dtype = np.int32) | ||
np.save('test_1d_int32.npy', arr) | ||
|
||
arr2 = np.zeros((3,2,5), dtype = np.float64) | ||
arr2[0,0,0] = 1.0 | ||
arr2[0,0,1] = 2.0 | ||
arr2[0,1,0] = 72.0 | ||
arr2[2,0,4] = 63.0 | ||
np.save('test_3d_double.npy', arr2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include <catch2/catch_test_macros.hpp> | ||
#include "aare/NumpyFile.hpp" | ||
#include "aare/NDArray.hpp" | ||
|
||
#include "test_config.hpp" | ||
|
||
using aare::NumpyFile; | ||
using aare::DType; | ||
TEST_CASE("Read a 1D numpy file with int32 data type"){ | ||
|
||
auto fpath = test_data_path() / "numpy" / "test_1d_int32.npy"; | ||
REQUIRE(std::filesystem::exists(fpath)); | ||
|
||
NumpyFile f(fpath); | ||
|
||
//we know the file contains 10 elements of np.int32 containing values 0-9 | ||
REQUIRE(f.dtype() == DType::INT32); | ||
REQUIRE(f.shape() == std::vector<size_t>{10}); | ||
|
||
//use the load function to read the full file into a NDArray | ||
auto data = f.load<int32_t,1>(); | ||
for(size_t i = 0; i < 10; i++){ | ||
REQUIRE(data(i) == i); | ||
} | ||
|
||
} | ||
|
||
TEST_CASE("Read a 3D numpy file with np.double data type"){ | ||
|
||
auto fpath = test_data_path() / "numpy" / "test_3d_double.npy"; | ||
REQUIRE(std::filesystem::exists(fpath)); | ||
|
||
NumpyFile f(fpath); | ||
|
||
//we know the file contains 10 elements of np.int32 containing values 0-9 | ||
REQUIRE(f.dtype() == DType::DOUBLE); | ||
REQUIRE(f.shape() == std::vector<size_t>{3,2,5}); | ||
|
||
//use the load function to read the full file into a NDArray | ||
//numpy code to generate the array | ||
// arr2[0,0,0] = 1.0 | ||
// arr2[0,0,1] = 2.0 | ||
// arr2[0,1,0] = 72.0 | ||
// arr2[2,0,4] = 63.0 | ||
|
||
auto data = f.load<double,3>(); | ||
REQUIRE(data(0,0,0) == 1.0); | ||
REQUIRE(data(0,0,1) == 2.0); | ||
REQUIRE(data(0,1,0) == 72.0); | ||
REQUIRE(data(2,0,4) == 63.0); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters